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

Side by Side Diff: core/src/fpdfdoc/doc_vt.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 months 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 | « core/src/fpdfdoc/doc_viewerPreferences.cpp ('k') | core/src/fpdfdoc/pdf_vt.h » ('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 "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 #include "../../include/fpdfdoc/fpdf_vt.h" 8 #include "../../include/fpdfdoc/fpdf_vt.h"
9 #include "pdf_vt.h" 9 #include "pdf_vt.h"
10 const FX_BYTE gFontSizeSteps[] = {» 4, 6, 8, 9, 10,»12, 14, 18, 20, 25,» 30, 35, 40, 45, 50,» 55, 60, 70, 80, 90,» 100, 110, 120, 130, 144}; 10 const uint8_t gFontSizeSteps[] = {» 4, 6, 8, 9, 10,»12, 14, 18, 20, 25,» 30, 35, 40, 45, 50,» 55, 60, 70, 80, 90,» 100, 110, 120, 130, 144};
11 #define PVT_RETURN_LENGTH 1 11 #define PVT_RETURN_LENGTH 1
12 #define PVT_DEFAULT_FONTSIZE 18.0f 12 #define PVT_DEFAULT_FONTSIZE 18.0f
13 #define PVTWORD_SCRIPT_NORMAL 0 13 #define PVTWORD_SCRIPT_NORMAL 0
14 #define PVTWORD_SCRIPT_SUPER 1 14 #define PVTWORD_SCRIPT_SUPER 1
15 #define PVTWORD_SCRIPT_SUB 2 15 #define PVTWORD_SCRIPT_SUB 2
16 #define PVT_FONTSCALE 0.001f 16 #define PVT_FONTSCALE 0.001f
17 #define PVT_PERCENT 0.01f 17 #define PVT_PERCENT 0.01f
18 #define PVT_HALF 0.5f 18 #define PVT_HALF 0.5f
19 CLine::CLine() 19 CLine::CLine()
20 { 20 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 { 55 {
56 ResetWordArray(); 56 ResetWordArray();
57 ResetLineArray(); 57 ResetLineArray();
58 } 58 }
59 void CSection::ResetLineArray() 59 void CSection::ResetLineArray()
60 { 60 {
61 m_LineArray.RemoveAll(); 61 m_LineArray.RemoveAll();
62 } 62 }
63 void CSection::ResetWordArray() 63 void CSection::ResetWordArray()
64 { 64 {
65 for (FX_INT32 i = 0, sz = m_WordArray.GetSize(); i < sz; i++) { 65 for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
66 delete m_WordArray.GetAt(i); 66 delete m_WordArray.GetAt(i);
67 } 67 }
68 m_WordArray.RemoveAll(); 68 m_WordArray.RemoveAll();
69 } 69 }
70 void CSection::ResetLinePlace() 70 void CSection::ResetLinePlace()
71 { 71 {
72 for (FX_INT32 i = 0, sz = m_LineArray.GetSize(); i < sz; i++) { 72 for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) {
73 if (CLine * pLine = m_LineArray.GetAt(i)) { 73 if (CLine * pLine = m_LineArray.GetAt(i)) {
74 pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1); 74 pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1);
75 } 75 }
76 } 76 }
77 } 77 }
78 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace & place, const CPVT_WordIn fo & wordinfo) 78 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace & place, const CPVT_WordIn fo & wordinfo)
79 { 79 {
80 if (CPVT_WordInfo * pWord = FX_NEW CPVT_WordInfo(wordinfo)) { 80 if (CPVT_WordInfo * pWord = FX_NEW CPVT_WordInfo(wordinfo)) {
81 FX_INT32 nWordIndex = FPDF_MAX(FPDF_MIN(place.nWordIndex, this->m_WordAr ray.GetSize()), 0); 81 int32_t nWordIndex = FPDF_MAX(FPDF_MIN(place.nWordIndex, this->m_WordArr ay.GetSize()), 0);
82 if (nWordIndex == m_WordArray.GetSize()) { 82 if (nWordIndex == m_WordArray.GetSize()) {
83 m_WordArray.Add(pWord); 83 m_WordArray.Add(pWord);
84 } else { 84 } else {
85 m_WordArray.InsertAt(nWordIndex, pWord); 85 m_WordArray.InsertAt(nWordIndex, pWord);
86 } 86 }
87 } 87 }
88 return place; 88 return place;
89 } 89 }
90 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo & lineinfo) 90 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo & lineinfo)
91 { 91 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return pNextLine->GetBeginWordPlace(); 155 return pNextLine->GetBeginWordPlace();
156 } 156 }
157 } else { 157 } else {
158 return pLine->GetNextWordPlace(place); 158 return pLine->GetNextWordPlace(place);
159 } 159 }
160 } 160 }
161 return place; 161 return place;
162 } 162 }
163 void CSection::UpdateWordPlace(CPVT_WordPlace & place) const 163 void CSection::UpdateWordPlace(CPVT_WordPlace & place) const
164 { 164 {
165 FX_INT32 nLeft = 0; 165 int32_t nLeft = 0;
166 FX_INT32 nRight = m_LineArray.GetSize() - 1; 166 int32_t nRight = m_LineArray.GetSize() - 1;
167 FX_INT32 nMid = (nLeft + nRight) / 2; 167 int32_t nMid = (nLeft + nRight) / 2;
168 while (nLeft <= nRight) { 168 while (nLeft <= nRight) {
169 if (CLine * pLine = m_LineArray.GetAt(nMid)) { 169 if (CLine * pLine = m_LineArray.GetAt(nMid)) {
170 if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { 170 if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
171 nRight = nMid - 1; 171 nRight = nMid - 1;
172 nMid = (nLeft + nRight) / 2; 172 nMid = (nLeft + nRight) / 2;
173 } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) { 173 } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) {
174 nLeft = nMid + 1; 174 nLeft = nMid + 1;
175 nMid = (nLeft + nRight) / 2; 175 nMid = (nLeft + nRight) / 2;
176 } else { 176 } else {
177 place.nLineIndex = nMid; 177 place.nLineIndex = nMid;
178 return; 178 return;
179 } 179 }
180 } else { 180 } else {
181 break; 181 break;
182 } 182 }
183 } 183 }
184 } 184 }
185 CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point & point) const 185 CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point & point) const
186 { 186 {
187 ASSERT(m_pVT != NULL); 187 ASSERT(m_pVT != NULL);
188 CPVT_WordPlace place = GetBeginWordPlace(); 188 CPVT_WordPlace place = GetBeginWordPlace();
189 FX_BOOL bUp = TRUE; 189 FX_BOOL bUp = TRUE;
190 FX_BOOL bDown = TRUE; 190 FX_BOOL bDown = TRUE;
191 FX_INT32 nLeft = 0; 191 int32_t nLeft = 0;
192 FX_INT32 nRight = m_LineArray.GetSize() - 1; 192 int32_t nRight = m_LineArray.GetSize() - 1;
193 FX_INT32 nMid = m_LineArray.GetSize() / 2; 193 int32_t nMid = m_LineArray.GetSize() / 2;
194 FX_FLOAT fTop = 0; 194 FX_FLOAT fTop = 0;
195 FX_FLOAT fBottom = 0; 195 FX_FLOAT fBottom = 0;
196 while (nLeft <= nRight) { 196 while (nLeft <= nRight) {
197 if (CLine * pLine = m_LineArray.GetAt(nMid)) { 197 if (CLine * pLine = m_LineArray.GetAt(nMid)) {
198 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_ pVT->GetLineLeading(m_SecInfo); 198 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_ pVT->GetLineLeading(m_SecInfo);
199 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent; 199 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
200 if (IsFloatBigger(point.y, fTop)) { 200 if (IsFloatBigger(point.y, fTop)) {
201 bUp = FALSE; 201 bUp = FALSE;
202 } 202 }
203 if (IsFloatSmaller(point.y, fBottom)) { 203 if (IsFloatSmaller(point.y, fBottom)) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 return GetBeginWordPlace(); 237 return GetBeginWordPlace();
238 } 238 }
239 CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx, const CPVT_WordRange & ran ge) const 239 CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx, const CPVT_WordRange & ran ge) const
240 { 240 {
241 CPVT_WordPlace wordplace = range.BeginPos; 241 CPVT_WordPlace wordplace = range.BeginPos;
242 wordplace.nWordIndex = -1; 242 wordplace.nWordIndex = -1;
243 if (!m_pVT) { 243 if (!m_pVT) {
244 return wordplace; 244 return wordplace;
245 } 245 }
246 FX_INT32 nLeft = range.BeginPos.nWordIndex; 246 int32_t nLeft = range.BeginPos.nWordIndex;
247 FX_INT32 nRight = range.EndPos.nWordIndex + 1; 247 int32_t nRight = range.EndPos.nWordIndex + 1;
248 FX_INT32 nMid = (nLeft + nRight) / 2; 248 int32_t nMid = (nLeft + nRight) / 2;
249 while (nLeft < nRight) { 249 while (nLeft < nRight) {
250 if (nMid == nLeft) { 250 if (nMid == nLeft) {
251 break; 251 break;
252 } 252 }
253 if (nMid == nRight) { 253 if (nMid == nRight) {
254 nMid--; 254 nMid--;
255 break; 255 break;
256 } 256 }
257 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) { 257 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) {
258 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) { 258 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) {
259 nLeft = nMid; 259 nLeft = nMid;
260 nMid = (nLeft + nRight) / 2; 260 nMid = (nLeft + nRight) / 2;
261 continue; 261 continue;
262 } else { 262 } else {
263 nRight = nMid; 263 nRight = nMid;
264 nMid = (nLeft + nRight) / 2; 264 nMid = (nLeft + nRight) / 2;
265 continue; 265 continue;
266 } 266 }
267 } else { 267 } else {
268 break; 268 break;
269 } 269 }
270 } 270 }
271 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) { 271 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) {
272 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) { 272 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) {
273 wordplace.nWordIndex = nMid; 273 wordplace.nWordIndex = nMid;
274 } 274 }
275 } 275 }
276 return wordplace; 276 return wordplace;
277 } 277 }
278 void CSection::ClearLeftWords(FX_INT32 nWordIndex) 278 void CSection::ClearLeftWords(int32_t nWordIndex)
279 { 279 {
280 for (FX_INT32 i = nWordIndex; i >= 0; i--) { 280 for (int32_t i = nWordIndex; i >= 0; i--) {
281 delete m_WordArray.GetAt(i); 281 delete m_WordArray.GetAt(i);
282 m_WordArray.RemoveAt(i); 282 m_WordArray.RemoveAt(i);
283 } 283 }
284 } 284 }
285 void CSection::ClearRightWords(FX_INT32 nWordIndex) 285 void CSection::ClearRightWords(int32_t nWordIndex)
286 { 286 {
287 for (FX_INT32 i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) { 287 for (int32_t i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) {
288 delete m_WordArray.GetAt(i); 288 delete m_WordArray.GetAt(i);
289 m_WordArray.RemoveAt(i); 289 m_WordArray.RemoveAt(i);
290 } 290 }
291 } 291 }
292 void CSection::ClearMidWords(FX_INT32 nBeginIndex, FX_INT32 nEndIndex) 292 void CSection::ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex)
293 { 293 {
294 for (FX_INT32 i = nEndIndex; i > nBeginIndex; i--) { 294 for (int32_t i = nEndIndex; i > nBeginIndex; i--) {
295 delete m_WordArray.GetAt(i); 295 delete m_WordArray.GetAt(i);
296 m_WordArray.RemoveAt(i); 296 m_WordArray.RemoveAt(i);
297 } 297 }
298 } 298 }
299 void CSection::ClearWords(const CPVT_WordRange & PlaceRange) 299 void CSection::ClearWords(const CPVT_WordRange & PlaceRange)
300 { 300 {
301 CPVT_WordPlace SecBeginPos = GetBeginWordPlace(); 301 CPVT_WordPlace SecBeginPos = GetBeginWordPlace();
302 CPVT_WordPlace SecEndPos = GetEndWordPlace(); 302 CPVT_WordPlace SecEndPos = GetEndWordPlace();
303 if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) { 303 if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) {
304 if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) { 304 if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
(...skipping 20 matching lines...) Expand all
325 } 325 }
326 CPVT_FloatRect CTypeset::CharArray() 326 CPVT_FloatRect CTypeset::CharArray()
327 { 327 {
328 ASSERT(m_pSection != NULL); 328 ASSERT(m_pSection != NULL);
329 ASSERT(m_pVT != NULL); 329 ASSERT(m_pVT != NULL);
330 FX_FLOAT fLineAscent = m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_ pVT->GetFontSize()); 330 FX_FLOAT fLineAscent = m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_ pVT->GetFontSize());
331 FX_FLOAT fLineDescent = m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize()); 331 FX_FLOAT fLineDescent = m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
332 m_rcRet.Default(); 332 m_rcRet.Default();
333 FX_FLOAT x = 0.0f, y = 0.0f; 333 FX_FLOAT x = 0.0f, y = 0.0f;
334 FX_FLOAT fNextWidth; 334 FX_FLOAT fNextWidth;
335 FX_INT32 nStart = 0; 335 int32_t nStart = 0;
336 FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() / (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray); 336 FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() / (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray);
337 if (CLine * pLine = m_pSection->m_LineArray.GetAt(0)) { 337 if (CLine * pLine = m_pSection->m_LineArray.GetAt(0)) {
338 x = 0.0f; 338 x = 0.0f;
339 y += m_pVT->GetLineLeading(m_pSection->m_SecInfo); 339 y += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
340 y += fLineAscent; 340 y += fLineAscent;
341 nStart = 0; 341 nStart = 0;
342 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { 342 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
343 case 0: 343 case 0:
344 pLine->m_LineInfo.fLineX = fNodeWidth * PVT_HALF; 344 pLine->m_LineInfo.fLineX = fNodeWidth * PVT_HALF;
345 break; 345 break;
346 case 1: 346 case 1:
347 nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize( )) / 2; 347 nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize( )) / 2;
348 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF; 348 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF;
349 break; 349 break;
350 case 2: 350 case 2:
351 nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize() ; 351 nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize() ;
352 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF; 352 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF;
353 break; 353 break;
354 } 354 }
355 for (FX_INT32 w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++ ) { 355 for (int32_t w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++) {
356 if (w >= m_pVT->m_nCharArray) { 356 if (w >= m_pVT->m_nCharArray) {
357 break; 357 break;
358 } 358 }
359 fNextWidth = 0; 359 fNextWidth = 0;
360 if (CPVT_WordInfo * pNextWord = (CPVT_WordInfo *)m_pSection->m_WordA rray.GetAt(w + 1)) { 360 if (CPVT_WordInfo * pNextWord = (CPVT_WordInfo *)m_pSection->m_WordA rray.GetAt(w + 1)) {
361 pNextWord->fWordTail = 0; 361 pNextWord->fWordTail = 0;
362 fNextWidth = m_pVT->GetWordWidth(*pNextWord); 362 fNextWidth = m_pVT->GetWordWidth(*pNextWord);
363 } 363 }
364 if (CPVT_WordInfo * pWord = (CPVT_WordInfo *)m_pSection->m_WordArray .GetAt(w)) { 364 if (CPVT_WordInfo * pWord = (CPVT_WordInfo *)m_pSection->m_WordArray .GetAt(w)) {
365 pWord->fWordTail = 0; 365 pWord->fWordTail = 0;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 return TRUE; 584 return TRUE;
585 } else if (IsCJK(prevWord)) { 585 } else if (IsCJK(prevWord)) {
586 return TRUE; 586 return TRUE;
587 } 587 }
588 return FALSE; 588 return FALSE;
589 } 589 }
590 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) 590 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize)
591 { 591 {
592 ASSERT(m_pVT != NULL); 592 ASSERT(m_pVT != NULL);
593 ASSERT(m_pSection != NULL); 593 ASSERT(m_pSection != NULL);
594 FX_INT32 nLineHead = 0; 594 int32_t nLineHead = 0;
595 FX_INT32 nLineTail = 0; 595 int32_t nLineTail = 0;
596 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; 596 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f;
597 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f; 597 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f;
598 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f; 598 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f;
599 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f; 599 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f;
600 FX_INT32 nWordStartPos = 0; 600 int32_t nWordStartPos = 0;
601 FX_BOOL bFullWord = FALSE; 601 FX_BOOL bFullWord = FALSE;
602 FX_INT32 nLineFullWordIndex = 0; 602 int32_t nLineFullWordIndex = 0;
603 FX_INT32 nCharIndex = 0; 603 int32_t nCharIndex = 0;
604 CPVT_LineInfo line; 604 CPVT_LineInfo line;
605 FX_FLOAT fWordWidth = 0; 605 FX_FLOAT fWordWidth = 0;
606 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - m_pVT->GetLineInd ent(m_pSection->m_SecInfo), 0.0f); 606 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - m_pVT->GetLineInd ent(m_pSection->m_SecInfo), 0.0f);
607 FX_INT32 nTotalWords = m_pSection->m_WordArray.GetSize(); 607 int32_t nTotalWords = m_pSection->m_WordArray.GetSize();
608 FX_BOOL bOpened = FALSE; 608 FX_BOOL bOpened = FALSE;
609 if (nTotalWords > 0) { 609 if (nTotalWords > 0) {
610 FX_INT32 i = 0; 610 int32_t i = 0;
611 while (i < nTotalWords) { 611 while (i < nTotalWords) {
612 CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(i); 612 CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(i);
613 CPVT_WordInfo* pOldWord = pWord; 613 CPVT_WordInfo* pOldWord = pWord;
614 if (i > 0) { 614 if (i > 0) {
615 pOldWord = m_pSection->m_WordArray.GetAt(i - 1); 615 pOldWord = m_pSection->m_WordArray.GetAt(i - 1);
616 } 616 }
617 if (pWord) { 617 if (pWord) {
618 if (bTypeset) { 618 if (bTypeset) {
619 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, TRUE)); 619 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, TRUE));
620 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, TRUE)); 620 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, TRUE));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 case 1: 746 case 1:
747 fMinX = (fTypesetWidth - m_rcRet.Width()) * PVT_HALF; 747 fMinX = (fTypesetWidth - m_rcRet.Width()) * PVT_HALF;
748 break; 748 break;
749 case 2: 749 case 2:
750 fMinX = fTypesetWidth - m_rcRet.Width(); 750 fMinX = fTypesetWidth - m_rcRet.Width();
751 break; 751 break;
752 } 752 }
753 fMaxX = fMinX + m_rcRet.Width(); 753 fMaxX = fMinX + m_rcRet.Width();
754 fMinY = 0.0f; 754 fMinY = 0.0f;
755 fMaxY = m_rcRet.Height(); 755 fMaxY = m_rcRet.Height();
756 FX_INT32 nTotalLines = m_pSection->m_LineArray.GetSize(); 756 int32_t nTotalLines = m_pSection->m_LineArray.GetSize();
757 if (nTotalLines > 0) { 757 if (nTotalLines > 0) {
758 m_pSection->m_SecInfo.nTotalLine = nTotalLines; 758 m_pSection->m_SecInfo.nTotalLine = nTotalLines;
759 for (FX_INT32 l = 0; l < nTotalLines; l++) { 759 for (int32_t l = 0; l < nTotalLines; l++) {
760 if (CLine * pLine = m_pSection->m_LineArray.GetAt(l)) { 760 if (CLine * pLine = m_pSection->m_LineArray.GetAt(l)) {
761 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { 761 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
762 default: 762 default:
763 case 0: 763 case 0:
764 fPosX = 0; 764 fPosX = 0;
765 break; 765 break;
766 case 1: 766 case 1:
767 fPosX = (fTypesetWidth - pLine->m_LineInfo.fLineWidth) * PVT_HALF; 767 fPosX = (fTypesetWidth - pLine->m_LineInfo.fLineWidth) * PVT_HALF;
768 break; 768 break;
769 case 2: 769 case 2:
770 fPosX = fTypesetWidth - pLine->m_LineInfo.fLineWidth; 770 fPosX = fTypesetWidth - pLine->m_LineInfo.fLineWidth;
771 break; 771 break;
772 } 772 }
773 fPosX += fLineIndent; 773 fPosX += fLineIndent;
774 fPosY += m_pVT->GetLineLeading(m_pSection->m_SecInfo); 774 fPosY += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
775 fPosY += pLine->m_LineInfo.fLineAscent; 775 fPosY += pLine->m_LineInfo.fLineAscent;
776 pLine->m_LineInfo.fLineX = fPosX - fMinX; 776 pLine->m_LineInfo.fLineX = fPosX - fMinX;
777 pLine->m_LineInfo.fLineY = fPosY - fMinY; 777 pLine->m_LineInfo.fLineY = fPosY - fMinY;
778 for (FX_INT32 w = pLine->m_LineInfo.nBeginWordIndex; w <= pLine- >m_LineInfo.nEndWordIndex; w++) { 778 for (int32_t w = pLine->m_LineInfo.nBeginWordIndex; w <= pLine-> m_LineInfo.nEndWordIndex; w++) {
779 if (CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(w) ) { 779 if (CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(w) ) {
780 pWord->fWordX = fPosX - fMinX; 780 pWord->fWordX = fPosX - fMinX;
781 if (pWord->pWordProps) { 781 if (pWord->pWordProps) {
782 switch (pWord->pWordProps->nScriptType) { 782 switch (pWord->pWordProps->nScriptType) {
783 default: 783 default:
784 case PVTWORD_SCRIPT_NORMAL: 784 case PVTWORD_SCRIPT_NORMAL:
785 pWord->fWordY = fPosY - fMinY; 785 pWord->fWordY = fPosY - fMinY;
786 break; 786 break;
787 case PVTWORD_SCRIPT_SUPER: 787 case PVTWORD_SCRIPT_SUPER:
788 pWord->fWordY = fPosY - m_pVT->GetWordAscent (*pWord) - fMinY; 788 pWord->fWordY = fPosY - m_pVT->GetWordAscent (*pWord) - fMinY;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 pSection->ResetLinePlace(); 848 pSection->ResetLinePlace();
849 } 849 }
850 m_bInitial = TRUE; 850 m_bInitial = TRUE;
851 } 851 }
852 } 852 }
853 void CPDF_VariableText::ResetAll() 853 void CPDF_VariableText::ResetAll()
854 { 854 {
855 m_bInitial = FALSE; 855 m_bInitial = FALSE;
856 ResetSectionArray(); 856 ResetSectionArray();
857 } 857 }
858 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO RD word, FX_INT32 charset, 858 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO RD word, int32_t charset,
859 const CPVT_WordProps * pWordProps) 859 const CPVT_WordProps * pWordProps)
860 { 860 {
861 FX_INT32 nTotlaWords = this->GetTotalWords(); 861 int32_t nTotlaWords = this->GetTotalWords();
862 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { 862 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) {
863 return place; 863 return place;
864 } 864 }
865 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { 865 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) {
866 return place; 866 return place;
867 } 867 }
868 CPVT_WordPlace newplace = place; 868 CPVT_WordPlace newplace = place;
869 newplace.nWordIndex ++; 869 newplace.nWordIndex ++;
870 if (m_bRichText) { 870 if (m_bRichText) {
871 CPVT_WordProps * pNewProps = pWordProps ? FX_NEW CPVT_WordProps(*pWordPr ops) : FX_NEW CPVT_WordProps(); 871 CPVT_WordProps * pNewProps = pWordProps ? FX_NEW CPVT_WordProps(*pWordPr ops) : FX_NEW CPVT_WordProps();
872 if (pNewProps) { 872 if (pNewProps) {
873 pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps-> nFontIndex); 873 pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps-> nFontIndex);
874 return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps) ); 874 return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps) );
875 } 875 }
876 } else { 876 } else {
877 FX_INT32 nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWord FontIndex(word, charset, GetDefaultFontIndex()); 877 int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordF ontIndex(word, charset, GetDefaultFontIndex());
878 return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)) ; 878 return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)) ;
879 } 879 }
880 return place; 880 return place;
881 } 881 }
882 CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, co nst CPVT_SecProps * pSecProps, 882 CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, co nst CPVT_SecProps * pSecProps,
883 const CPVT_WordProps * pWordProps) 883 const CPVT_WordProps * pWordProps)
884 { 884 {
885 FX_INT32 nTotlaWords = this->GetTotalWords(); 885 int32_t nTotlaWords = this->GetTotalWords();
886 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { 886 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) {
887 return place; 887 return place;
888 } 888 }
889 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { 889 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) {
890 return place; 890 return place;
891 } 891 }
892 if (!m_bMultiLine) { 892 if (!m_bMultiLine) {
893 return place; 893 return place;
894 } 894 }
895 CPVT_WordPlace wordplace = place; 895 CPVT_WordPlace wordplace = place;
896 UpdateWordPlace(wordplace); 896 UpdateWordPlace(wordplace);
897 CPVT_WordPlace newplace = place; 897 CPVT_WordPlace newplace = place;
898 if (CSection * pSection = m_SectionArray.GetAt(wordplace.nSecIndex)) { 898 if (CSection * pSection = m_SectionArray.GetAt(wordplace.nSecIndex)) {
899 CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1); 899 CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1);
900 CPVT_SectionInfo secinfo; 900 CPVT_SectionInfo secinfo;
901 if (m_bRichText) { 901 if (m_bRichText) {
902 if (pSecProps) { 902 if (pSecProps) {
903 secinfo.pSecProps = FX_NEW CPVT_SecProps(*pSecProps); 903 secinfo.pSecProps = FX_NEW CPVT_SecProps(*pSecProps);
904 } 904 }
905 if (pWordProps) { 905 if (pWordProps) {
906 secinfo.pWordProps = FX_NEW CPVT_WordProps(*pWordProps); 906 secinfo.pWordProps = FX_NEW CPVT_WordProps(*pWordProps);
907 } 907 }
908 } 908 }
909 AddSection(NewPlace, secinfo); 909 AddSection(NewPlace, secinfo);
910 newplace = NewPlace; 910 newplace = NewPlace;
911 if (CSection * pNewSection = m_SectionArray.GetAt(NewPlace.nSecIndex)) { 911 if (CSection * pNewSection = m_SectionArray.GetAt(NewPlace.nSecIndex)) {
912 for (FX_INT32 w = wordplace.nWordIndex + 1, sz = pSection->m_WordArr ay.GetSize(); w < sz; w++) { 912 for (int32_t w = wordplace.nWordIndex + 1, sz = pSection->m_WordArra y.GetSize(); w < sz; w++) {
913 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(w)) { 913 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(w)) {
914 NewPlace.nWordIndex++; 914 NewPlace.nWordIndex++;
915 pNewSection->AddWord(NewPlace, *pWord); 915 pNewSection->AddWord(NewPlace, *pWord);
916 } 916 }
917 } 917 }
918 } 918 }
919 ClearSectionRightWords(wordplace); 919 ClearSectionRightWords(wordplace);
920 } 920 }
921 return newplace; 921 return newplace;
922 } 922 }
923 CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace & place, FX_LP CWSTR text, FX_INT32 charset, 923 CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace & place, FX_LP CWSTR text, int32_t charset,
924 const CPVT_SecProps * pSecProps, const CPVT_WordProps * pProps) 924 const CPVT_SecProps * pSecProps, const CPVT_WordProps * pProps)
925 { 925 {
926 CFX_WideString swText = text; 926 CFX_WideString swText = text;
927 CPVT_WordPlace wp = place; 927 CPVT_WordPlace wp = place;
928 for (FX_INT32 i = 0, sz = swText.GetLength(); i < sz; i++) { 928 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
929 CPVT_WordPlace oldwp = wp; 929 CPVT_WordPlace oldwp = wp;
930 FX_WORD word = swText.GetAt(i); 930 FX_WORD word = swText.GetAt(i);
931 switch (word) { 931 switch (word) {
932 case 0x0D: 932 case 0x0D:
933 if (m_bMultiLine) { 933 if (m_bMultiLine) {
934 if (swText.GetAt(i + 1) == 0x0A) { 934 if (swText.GetAt(i + 1) == 0x0A) {
935 i += 1; 935 i += 1;
936 } 936 }
937 wp = InsertSection(wp, pSecProps, pProps); 937 wp = InsertSection(wp, pSecProps, pProps);
938 } 938 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 return PlaceRange.BeginPos; 973 return PlaceRange.BeginPos;
974 } 974 }
975 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace & place) 975 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace & place)
976 { 976 {
977 return ClearRightWord(AjustLineHeader(place, TRUE)); 977 return ClearRightWord(AjustLineHeader(place, TRUE));
978 } 978 }
979 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace & place) 979 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace & place)
980 { 980 {
981 return ClearLeftWord(AjustLineHeader(place, TRUE)); 981 return ClearLeftWord(AjustLineHeader(place, TRUE));
982 } 982 }
983 void CPDF_VariableText::SetText(FX_LPCWSTR text, FX_INT32 charset, const CPVT_Se cProps * pSecProps, 983 void CPDF_VariableText::SetText(FX_LPCWSTR text, int32_t charset, const CPVT_Sec Props * pSecProps,
984 const CPVT_WordProps * pWordProps) 984 const CPVT_WordProps * pWordProps)
985 { 985 {
986 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); 986 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
987 CFX_WideString swText = text; 987 CFX_WideString swText = text;
988 CPVT_WordPlace wp(0, 0, -1); 988 CPVT_WordPlace wp(0, 0, -1);
989 CPVT_SectionInfo secinfo; 989 CPVT_SectionInfo secinfo;
990 if (m_bRichText) { 990 if (m_bRichText) {
991 if (pSecProps) { 991 if (pSecProps) {
992 secinfo.pSecProps = FX_NEW CPVT_SecProps(*pSecProps); 992 secinfo.pSecProps = FX_NEW CPVT_SecProps(*pSecProps);
993 } 993 }
994 if (pWordProps) { 994 if (pWordProps) {
995 secinfo.pWordProps = FX_NEW CPVT_WordProps(*pWordProps); 995 secinfo.pWordProps = FX_NEW CPVT_WordProps(*pWordProps);
996 } 996 }
997 } 997 }
998 if (CSection * pSection = m_SectionArray.GetAt(0)) { 998 if (CSection * pSection = m_SectionArray.GetAt(0)) {
999 pSection->m_SecInfo = secinfo; 999 pSection->m_SecInfo = secinfo;
1000 } 1000 }
1001 FX_INT32 nCharCount = 0; 1001 int32_t nCharCount = 0;
1002 for (FX_INT32 i = 0, sz = swText.GetLength(); i < sz; i++) { 1002 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
1003 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) { 1003 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) {
1004 break; 1004 break;
1005 } 1005 }
1006 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) { 1006 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) {
1007 break; 1007 break;
1008 } 1008 }
1009 FX_WORD word = swText.GetAt(i); 1009 FX_WORD word = swText.GetAt(i);
1010 switch (word) { 1010 switch (word) {
1011 case 0x0D: 1011 case 0x0D:
1012 if (m_bMultiLine) { 1012 if (m_bMultiLine) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 place = GetBeginWordPlace(); 1045 place = GetBeginWordPlace();
1046 } 1046 }
1047 if (place.nSecIndex >= m_SectionArray.GetSize()) { 1047 if (place.nSecIndex >= m_SectionArray.GetSize()) {
1048 place = GetEndWordPlace(); 1048 place = GetEndWordPlace();
1049 } 1049 }
1050 place = AjustLineHeader(place, TRUE); 1050 place = AjustLineHeader(place, TRUE);
1051 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1051 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1052 pSection->UpdateWordPlace(place); 1052 pSection->UpdateWordPlace(place);
1053 } 1053 }
1054 } 1054 }
1055 FX_INT32 CPDF_VariableText::WordPlaceToWordIndex(const CPVT_WordPlace & place) c onst 1055 int32_t CPDF_VariableText::WordPlaceToWordIndex(const CPVT_WordPlace & place) co nst
1056 { 1056 {
1057 CPVT_WordPlace newplace = place; 1057 CPVT_WordPlace newplace = place;
1058 UpdateWordPlace(newplace); 1058 UpdateWordPlace(newplace);
1059 FX_INT32 nIndex = 0; 1059 int32_t nIndex = 0;
1060 FX_INT32 i = 0; 1060 int32_t i = 0;
1061 FX_INT32 sz = 0; 1061 int32_t sz = 0;
1062 for (i = 0, sz = m_SectionArray.GetSize(); i < sz && i < newplace.nSecIndex; i++) { 1062 for (i = 0, sz = m_SectionArray.GetSize(); i < sz && i < newplace.nSecIndex; i++) {
1063 if (CSection * pSection = m_SectionArray.GetAt(i)) { 1063 if (CSection * pSection = m_SectionArray.GetAt(i)) {
1064 nIndex += pSection->m_WordArray.GetSize(); 1064 nIndex += pSection->m_WordArray.GetSize();
1065 if (i != m_SectionArray.GetSize() - 1) { 1065 if (i != m_SectionArray.GetSize() - 1) {
1066 nIndex += PVT_RETURN_LENGTH; 1066 nIndex += PVT_RETURN_LENGTH;
1067 } 1067 }
1068 } 1068 }
1069 } 1069 }
1070 if (i >= 0 && i < m_SectionArray.GetSize()) { 1070 if (i >= 0 && i < m_SectionArray.GetSize()) {
1071 nIndex += newplace.nWordIndex + PVT_RETURN_LENGTH; 1071 nIndex += newplace.nWordIndex + PVT_RETURN_LENGTH;
1072 } 1072 }
1073 return nIndex; 1073 return nIndex;
1074 } 1074 }
1075 CPVT_WordPlace CPDF_VariableText::WordIndexToWordPlace(FX_INT32 index) const 1075 CPVT_WordPlace CPDF_VariableText::WordIndexToWordPlace(int32_t index) const
1076 { 1076 {
1077 CPVT_WordPlace place = GetBeginWordPlace(); 1077 CPVT_WordPlace place = GetBeginWordPlace();
1078 FX_INT32 nOldIndex = 0 , nIndex = 0; 1078 int32_t nOldIndex = 0 , nIndex = 0;
1079 FX_BOOL bFind = FALSE; 1079 FX_BOOL bFind = FALSE;
1080 for (FX_INT32 i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) { 1080 for (int32_t i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) {
1081 if (CSection * pSection = m_SectionArray.GetAt(i)) { 1081 if (CSection * pSection = m_SectionArray.GetAt(i)) {
1082 nIndex += pSection->m_WordArray.GetSize(); 1082 nIndex += pSection->m_WordArray.GetSize();
1083 if (nIndex == index) { 1083 if (nIndex == index) {
1084 place = pSection->GetEndWordPlace(); 1084 place = pSection->GetEndWordPlace();
1085 bFind = TRUE; 1085 bFind = TRUE;
1086 break; 1086 break;
1087 } else if (nIndex > index) { 1087 } else if (nIndex > index) {
1088 place.nSecIndex = i; 1088 place.nSecIndex = i;
1089 place.nWordIndex = index - nOldIndex - 1; 1089 place.nWordIndex = index - nOldIndex - 1;
1090 pSection->UpdateWordPlace(place); 1090 pSection->UpdateWordPlace(place);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 } else { 1152 } else {
1153 return pSection->GetNextWordPlace(place); 1153 return pSection->GetNextWordPlace(place);
1154 } 1154 }
1155 } 1155 }
1156 return place; 1156 return place;
1157 } 1157 }
1158 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons t 1158 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons t
1159 { 1159 {
1160 CPDF_Point pt = OutToIn(point); 1160 CPDF_Point pt = OutToIn(point);
1161 CPVT_WordPlace place = GetBeginWordPlace(); 1161 CPVT_WordPlace place = GetBeginWordPlace();
1162 FX_INT32 nLeft = 0; 1162 int32_t nLeft = 0;
1163 FX_INT32 nRight = m_SectionArray.GetSize() - 1; 1163 int32_t nRight = m_SectionArray.GetSize() - 1;
1164 FX_INT32 nMid = m_SectionArray.GetSize() / 2; 1164 int32_t nMid = m_SectionArray.GetSize() / 2;
1165 FX_BOOL bUp = TRUE; 1165 FX_BOOL bUp = TRUE;
1166 FX_BOOL bDown = TRUE; 1166 FX_BOOL bDown = TRUE;
1167 while (nLeft <= nRight) { 1167 while (nLeft <= nRight) {
1168 if (CSection * pSection = m_SectionArray.GetAt(nMid)) { 1168 if (CSection * pSection = m_SectionArray.GetAt(nMid)) {
1169 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) { 1169 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) {
1170 bUp = FALSE; 1170 bUp = FALSE;
1171 } 1171 }
1172 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) { 1172 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) {
1173 bDown = FALSE; 1173 bDown = FALSE;
1174 } 1174 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 { 1251 {
1252 return CPVT_WordPlace(place.nSecIndex, 0, -1); 1252 return CPVT_WordPlace(place.nSecIndex, 0, -1);
1253 } 1253 }
1254 CPVT_WordPlace CPDF_VariableText::GetSectionEndPlace(const CPVT_WordPlace & plac e) const 1254 CPVT_WordPlace CPDF_VariableText::GetSectionEndPlace(const CPVT_WordPlace & plac e) const
1255 { 1255 {
1256 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1256 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1257 return pSection->GetEndWordPlace(); 1257 return pSection->GetEndWordPlace();
1258 } 1258 }
1259 return place; 1259 return place;
1260 } 1260 }
1261 FX_INT32 CPDF_VariableText::GetTotalWords() const 1261 int32_t CPDF_VariableText::GetTotalWords() const
1262 { 1262 {
1263 FX_INT32 nTotal = 0; 1263 int32_t nTotal = 0;
1264 for (FX_INT32 i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) 1264 for (int32_t i = 0, sz = m_SectionArray.GetSize(); i < sz; i++)
1265 if (CSection * pSection = m_SectionArray.GetAt(i)) { 1265 if (CSection * pSection = m_SectionArray.GetAt(i)) {
1266 nTotal += (pSection->m_WordArray.GetSize() + PVT_RETURN_LENGTH); 1266 nTotal += (pSection->m_WordArray.GetSize() + PVT_RETURN_LENGTH);
1267 } 1267 }
1268 return nTotal - PVT_RETURN_LENGTH; 1268 return nTotal - PVT_RETURN_LENGTH;
1269 } 1269 }
1270 void CPDF_VariableText::ResetSectionArray() 1270 void CPDF_VariableText::ResetSectionArray()
1271 { 1271 {
1272 for (FX_INT32 s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1272 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1273 delete m_SectionArray.GetAt(s); 1273 delete m_SectionArray.GetAt(s);
1274 } 1274 }
1275 m_SectionArray.RemoveAll(); 1275 m_SectionArray.RemoveAll();
1276 } 1276 }
1277 CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo) 1277 CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo)
1278 { 1278 {
1279 if (IsValid() && !m_bMultiLine) { 1279 if (IsValid() && !m_bMultiLine) {
1280 return place; 1280 return place;
1281 } 1281 }
1282 FX_INT32 nSecIndex = FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSi ze()), 0); 1282 int32_t nSecIndex = FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSiz e()), 0);
1283 CSection * pSection = FX_NEW CSection(this); 1283 CSection* pSection = new CSection(this);
1284 if (!pSection) {
1285 return place;
1286 }
1287 pSection->m_SecInfo = secinfo; 1284 pSection->m_SecInfo = secinfo;
1288 pSection->SecPlace.nSecIndex = nSecIndex; 1285 pSection->SecPlace.nSecIndex = nSecIndex;
1289 if (nSecIndex == m_SectionArray.GetSize()) { 1286 if (nSecIndex == m_SectionArray.GetSize()) {
1290 m_SectionArray.Add(pSection); 1287 m_SectionArray.Add(pSection);
1291 } else { 1288 } else {
1292 m_SectionArray.InsertAt(nSecIndex, pSection); 1289 m_SectionArray.InsertAt(nSecIndex, pSection);
1293 } 1290 }
1294 return place; 1291 return place;
1295 } 1292 }
1296 CPVT_WordPlace CPDF_VariableText::AddLine(const CPVT_WordPlace & place, const CP VT_LineInfo & lineinfo) 1293 CPVT_WordPlace CPDF_VariableText::AddLine(const CPVT_WordPlace & place, const CP VT_LineInfo & lineinfo)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 return FALSE; 1351 return FALSE;
1355 } 1352 }
1356 CPDF_Rect CPDF_VariableText::GetContentRect() const 1353 CPDF_Rect CPDF_VariableText::GetContentRect() const
1357 { 1354 {
1358 return InToOut(CPDF_EditContainer::GetContentRect()); 1355 return InToOut(CPDF_EditContainer::GetContentRect());
1359 } 1356 }
1360 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_B OOL bFactFontSize) 1357 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_B OOL bFactFontSize)
1361 { 1358 {
1362 return m_bRichText && WordInfo.pWordProps ? (WordInfo.pWordProps->nScriptTyp e == PVTWORD_SCRIPT_NORMAL || bFactFontSize ? WordInfo.pWordProps->fFontSize : W ordInfo.pWordProps->fFontSize * PVT_HALF) : GetFontSize(); 1359 return m_bRichText && WordInfo.pWordProps ? (WordInfo.pWordProps->nScriptTyp e == PVTWORD_SCRIPT_NORMAL || bFactFontSize ? WordInfo.pWordProps->fFontSize : W ordInfo.pWordProps->fFontSize * PVT_HALF) : GetFontSize();
1363 } 1360 }
1364 FX_INT32 CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo & WordInfo) 1361 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo & WordInfo)
1365 { 1362 {
1366 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nFontIndex : WordInfo.nFontIndex; 1363 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nFontIndex : WordInfo.nFontIndex;
1367 } 1364 }
1368 FX_FLOAT CPDF_VariableText::GetWordWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_W ORD SubWord, 1365 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, FX_WORD Word, FX_WO RD SubWord,
1369 FX_FLOAT fCharSpace, FX_INT32 nHorzScale, 1366 FX_FLOAT fCharSpace, int32_t nHorzScale,
1370 FX_FLOAT fFontSize, FX_FLOAT fWordTail, FX_INT32 nWordStyle) 1367 FX_FLOAT fFontSize, FX_FLOAT fWordTail, int32_t nWordStyle)
1371 { 1368 {
1372 return (GetCharWidth(nFontIndex, Word, SubWord, nWordStyle) * fFontSize * PV T_FONTSCALE + fCharSpace) * nHorzScale * PVT_PERCENT + fWordTail; 1369 return (GetCharWidth(nFontIndex, Word, SubWord, nWordStyle) * fFontSize * PV T_FONTSCALE + fCharSpace) * nHorzScale * PVT_PERCENT + fWordTail;
1373 } 1370 }
1374 FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo & WordInfo) 1371 FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo & WordInfo)
1375 { 1372 {
1376 return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(), GetCharSpace(WordInfo), GetHorzScale(WordInfo), 1373 return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(), GetCharSpace(WordInfo), GetHorzScale(WordInfo),
1377 GetWordFontSize(WordInfo), WordInfo.fWordTail, 1374 GetWordFontSize(WordInfo), WordInfo.fWordTail,
1378 WordInfo.pWordProps ? WordInfo.pWordProps->nWordStyle : 0); 1375 WordInfo.pWordProps ? WordInfo.pWordProps->nWordStyle : 0);
1379 } 1376 }
1380 FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo & SecInfo) 1377 FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo & SecInfo)
1381 { 1378 {
1382 return m_bRichText && SecInfo.pWordProps ? GetFontAscent(SecInfo.pWordProps- >nFontIndex, SecInfo.pWordProps->fFontSize) : 1379 return m_bRichText && SecInfo.pWordProps ? GetFontAscent(SecInfo.pWordProps- >nFontIndex, SecInfo.pWordProps->fFontSize) :
1383 GetFontAscent(GetDefaultFontIndex(), GetFontSize()); 1380 GetFontAscent(GetDefaultFontIndex(), GetFontSize());
1384 } 1381 }
1385 FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo & SecInfo) 1382 FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo & SecInfo)
1386 { 1383 {
1387 return m_bRichText && SecInfo.pWordProps ? GetFontDescent(SecInfo.pWordProps ->nFontIndex, SecInfo.pWordProps->fFontSize) : 1384 return m_bRichText && SecInfo.pWordProps ? GetFontDescent(SecInfo.pWordProps ->nFontIndex, SecInfo.pWordProps->fFontSize) :
1388 GetFontDescent(GetDefaultFontIndex(), GetFontSize()); 1385 GetFontDescent(GetDefaultFontIndex(), GetFontSize());
1389 } 1386 }
1390 FX_FLOAT CPDF_VariableText::GetFontAscent(FX_INT32 nFontIndex, FX_FLOAT fFontSiz e) 1387 FX_FLOAT CPDF_VariableText::GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize )
1391 { 1388 {
1392 return (FX_FLOAT)GetTypeAscent(nFontIndex) * fFontSize * PVT_FONTSCALE; 1389 return (FX_FLOAT)GetTypeAscent(nFontIndex) * fFontSize * PVT_FONTSCALE;
1393 } 1390 }
1394 FX_FLOAT CPDF_VariableText::GetFontDescent(FX_INT32 nFontIndex, FX_FLOAT fFontSi ze) 1391 FX_FLOAT CPDF_VariableText::GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSiz e)
1395 { 1392 {
1396 return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * PVT_FONTSCALE; 1393 return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * PVT_FONTSCALE;
1397 } 1394 }
1398 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLO AT fFontSize) 1395 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLO AT fFontSize)
1399 { 1396 {
1400 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize); 1397 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize);
1401 } 1398 }
1402 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FL OAT fFontSize) 1399 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FL OAT fFontSize)
1403 { 1400 {
1404 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize); 1401 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize);
1405 } 1402 }
1406 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOO L bFactFontSize) 1403 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOO L bFactFontSize)
1407 { 1404 {
1408 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, b FactFontSize)); 1405 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, b FactFontSize));
1409 } 1406 }
1410 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BO OL bFactFontSize) 1407 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BO OL bFactFontSize)
1411 { 1408 {
1412 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, bFactFontSize)); 1409 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, bFactFontSize));
1413 } 1410 }
1414 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo & SecInfo) 1411 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo & SecInfo)
1415 { 1412 {
1416 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineLeading : m_fLineLeading; 1413 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineLeading : m_fLineLeading;
1417 } 1414 }
1418 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo & SecInfo) 1415 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo & SecInfo)
1419 { 1416 {
1420 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineIndent : 0 .0f; 1417 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineIndent : 0 .0f;
1421 } 1418 }
1422 FX_INT32 CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo) 1419 int32_t CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo)
1423 { 1420 {
1424 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->nAlignment : th is->m_nAlignment; 1421 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->nAlignment : th is->m_nAlignment;
1425 } 1422 }
1426 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo & WordInfo) 1423 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo & WordInfo)
1427 { 1424 {
1428 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace : m_fCharSpace; 1425 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace : m_fCharSpace;
1429 } 1426 }
1430 FX_INT32 CPDF_VariableText::GetHorzScale(const CPVT_WordInfo & WordInfo) 1427 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo & WordInfo)
1431 { 1428 {
1432 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale : m_nHorzScale; 1429 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale : m_nHorzScale;
1433 } 1430 }
1434 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place) 1431 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place)
1435 { 1432 {
1436 CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE); 1433 CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE);
1437 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1434 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1438 for (FX_INT32 w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWo rdIndex; w--) { 1435 for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWor dIndex; w--) {
1439 delete pSection->m_WordArray.GetAt(w); 1436 delete pSection->m_WordArray.GetAt(w);
1440 pSection->m_WordArray.RemoveAt(w); 1437 pSection->m_WordArray.RemoveAt(w);
1441 } 1438 }
1442 } 1439 }
1443 } 1440 }
1444 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const 1441 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const
1445 { 1442 {
1446 if (place.nWordIndex < 0 && place.nLineIndex > 0) { 1443 if (place.nWordIndex < 0 && place.nLineIndex > 0) {
1447 if (bPrevOrNext) { 1444 if (bPrevOrNext) {
1448 return GetPrevWordPlace(place); 1445 return GetPrevWordPlace(place);
(...skipping 13 matching lines...) Expand all
1462 delete pSection; 1459 delete pSection;
1463 m_SectionArray.RemoveAt(place.nSecIndex); 1460 m_SectionArray.RemoveAt(place.nSecIndex);
1464 return TRUE; 1461 return TRUE;
1465 } 1462 }
1466 } 1463 }
1467 return FALSE; 1464 return FALSE;
1468 } 1465 }
1469 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange & PlaceRange) 1466 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange & PlaceRange)
1470 { 1467 {
1471 CPVT_WordPlace wordplace; 1468 CPVT_WordPlace wordplace;
1472 for (FX_INT32 s = PlaceRange.EndPos.nSecIndex; s > PlaceRange.BeginPos.nSecI ndex; s--) { 1469 for (int32_t s = PlaceRange.EndPos.nSecIndex; s > PlaceRange.BeginPos.nSecIn dex; s--) {
1473 wordplace.nSecIndex = s; 1470 wordplace.nSecIndex = s;
1474 ClearEmptySection(wordplace); 1471 ClearEmptySection(wordplace);
1475 } 1472 }
1476 } 1473 }
1477 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace & place) 1474 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace & place)
1478 { 1475 {
1479 CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE); 1476 CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE);
1480 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { 1477 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) {
1481 if (CSection * pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { 1478 if (CSection * pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) {
1482 for (FX_INT32 w = 0, sz = pNextSection->m_WordArray.GetSize(); w < s z; w++) { 1479 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz ; w++) {
1483 if (CPVT_WordInfo * pWord = pNextSection->m_WordArray.GetAt(w)) { 1480 if (CPVT_WordInfo * pWord = pNextSection->m_WordArray.GetAt(w)) {
1484 oldplace.nWordIndex ++; 1481 oldplace.nWordIndex ++;
1485 pSection->AddWord(oldplace, *pWord); 1482 pSection->AddWord(oldplace, *pWord);
1486 } 1483 }
1487 } 1484 }
1488 } 1485 }
1489 delete pNextSection; 1486 delete pNextSection;
1490 m_SectionArray.RemoveAt(place.nSecIndex + 1); 1487 m_SectionArray.RemoveAt(place.nSecIndex + 1);
1491 } 1488 }
1492 } 1489 }
1493 void CPDF_VariableText::ClearWords(const CPVT_WordRange & PlaceRange) 1490 void CPDF_VariableText::ClearWords(const CPVT_WordRange & PlaceRange)
1494 { 1491 {
1495 CPVT_WordRange NewRange; 1492 CPVT_WordRange NewRange;
1496 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE); 1493 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE);
1497 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE); 1494 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE);
1498 for (FX_INT32 s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecInde x; s--) { 1495 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex ; s--) {
1499 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1496 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1500 pSection->ClearWords(NewRange); 1497 pSection->ClearWords(NewRange);
1501 } 1498 }
1502 } 1499 }
1503 } 1500 }
1504 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace & place) 1501 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace & place)
1505 { 1502 {
1506 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1503 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1507 CPVT_WordPlace leftplace = this->GetPrevWordPlace(place); 1504 CPVT_WordPlace leftplace = this->GetPrevWordPlace(place);
1508 if (leftplace != place) { 1505 if (leftplace != place) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 rcRet = RearrangeSections(CPVT_WordRange(GetBeginWordPlace(), GetEnd WordPlace())); 1548 rcRet = RearrangeSections(CPVT_WordRange(GetBeginWordPlace(), GetEnd WordPlace()));
1552 } else { 1549 } else {
1553 rcRet = RearrangeSections(PlaceRange); 1550 rcRet = RearrangeSections(PlaceRange);
1554 } 1551 }
1555 } 1552 }
1556 SetContentRect(rcRet); 1553 SetContentRect(rcRet);
1557 return rcRet; 1554 return rcRet;
1558 } 1555 }
1559 FX_FLOAT CPDF_VariableText::GetAutoFontSize() 1556 FX_FLOAT CPDF_VariableText::GetAutoFontSize()
1560 { 1557 {
1561 FX_INT32 nTotal = sizeof(gFontSizeSteps) / sizeof(FX_BYTE); 1558 int32_t nTotal = sizeof(gFontSizeSteps) / sizeof(uint8_t);
1562 if (IsMultiLine()) { 1559 if (IsMultiLine()) {
1563 nTotal /= 4; 1560 nTotal /= 4;
1564 } 1561 }
1565 if (nTotal <= 0) { 1562 if (nTotal <= 0) {
1566 return 0; 1563 return 0;
1567 } 1564 }
1568 if (GetPlateWidth() <= 0) { 1565 if (GetPlateWidth() <= 0) {
1569 return 0; 1566 return 0;
1570 } 1567 }
1571 FX_INT32 nLeft = 0; 1568 int32_t nLeft = 0;
1572 FX_INT32 nRight = nTotal - 1; 1569 int32_t nRight = nTotal - 1;
1573 FX_INT32 nMid = nTotal / 2; 1570 int32_t nMid = nTotal / 2;
1574 while (nLeft <= nRight) { 1571 while (nLeft <= nRight) {
1575 if (IsBigger(gFontSizeSteps[nMid])) { 1572 if (IsBigger(gFontSizeSteps[nMid])) {
1576 nRight = nMid - 1; 1573 nRight = nMid - 1;
1577 nMid = (nLeft + nRight) / 2; 1574 nMid = (nLeft + nRight) / 2;
1578 continue; 1575 continue;
1579 } else { 1576 } else {
1580 nLeft = nMid + 1; 1577 nLeft = nMid + 1;
1581 nMid = (nLeft + nRight) / 2; 1578 nMid = (nLeft + nRight) / 2;
1582 continue; 1579 continue;
1583 } 1580 }
1584 } 1581 }
1585 return (FX_FLOAT)gFontSizeSteps[nMid]; 1582 return (FX_FLOAT)gFontSizeSteps[nMid];
1586 } 1583 }
1587 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) 1584 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize)
1588 { 1585 {
1589 FX_BOOL bBigger = FALSE; 1586 FX_BOOL bBigger = FALSE;
1590 CPVT_Size szTotal; 1587 CPVT_Size szTotal;
1591 for (FX_INT32 s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1588 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1592 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1589 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1593 CPVT_Size size = pSection->GetSectionSize(fFontSize); 1590 CPVT_Size size = pSection->GetSectionSize(fFontSize);
1594 szTotal.x = FPDF_MAX(size.x, szTotal.x); 1591 szTotal.x = FPDF_MAX(size.x, szTotal.x);
1595 szTotal.y += size.y; 1592 szTotal.y += size.y;
1596 if (IsFloatBigger(szTotal.x, GetPlateWidth()) 1593 if (IsFloatBigger(szTotal.x, GetPlateWidth())
1597 || IsFloatBigger(szTotal.y, GetPlateHeight()) 1594 || IsFloatBigger(szTotal.y, GetPlateHeight())
1598 ) { 1595 ) {
1599 bBigger = TRUE; 1596 bBigger = TRUE;
1600 break; 1597 break;
1601 } 1598 }
1602 } 1599 }
1603 } 1600 }
1604 return bBigger; 1601 return bBigger;
1605 } 1602 }
1606 CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place Range) 1603 CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place Range)
1607 { 1604 {
1608 CPVT_WordPlace place; 1605 CPVT_WordPlace place;
1609 FX_FLOAT fPosY = 0; 1606 FX_FLOAT fPosY = 0;
1610 FX_FLOAT fOldHeight; 1607 FX_FLOAT fOldHeight;
1611 FX_INT32 nSSecIndex = PlaceRange.BeginPos.nSecIndex; 1608 int32_t nSSecIndex = PlaceRange.BeginPos.nSecIndex;
1612 FX_INT32 nESecIndex = PlaceRange.EndPos.nSecIndex; 1609 int32_t nESecIndex = PlaceRange.EndPos.nSecIndex;
1613 CPVT_FloatRect rcRet; 1610 CPVT_FloatRect rcRet;
1614 for (FX_INT32 s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1611 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1615 place.nSecIndex = s; 1612 place.nSecIndex = s;
1616 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1613 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1617 pSection->SecPlace = place; 1614 pSection->SecPlace = place;
1618 CPVT_FloatRect rcSec = pSection->m_SecInfo.rcSection; 1615 CPVT_FloatRect rcSec = pSection->m_SecInfo.rcSection;
1619 if (s >= nSSecIndex) { 1616 if (s >= nSSecIndex) {
1620 if (s <= nESecIndex) { 1617 if (s <= nESecIndex) {
1621 rcSec = pSection->Rearrange(); 1618 rcSec = pSection->Rearrange();
1622 rcSec.top += fPosY; 1619 rcSec.top += fPosY;
1623 rcSec.bottom += fPosY; 1620 rcSec.bottom += fPosY;
1624 } else { 1621 } else {
(...skipping 10 matching lines...) Expand all
1635 rcRet.left = FPDF_MIN(rcSec.left, rcRet.left); 1632 rcRet.left = FPDF_MIN(rcSec.left, rcRet.left);
1636 rcRet.top = FPDF_MIN(rcSec.top, rcRet.top); 1633 rcRet.top = FPDF_MIN(rcSec.top, rcRet.top);
1637 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right); 1634 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right);
1638 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom); 1635 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom);
1639 } 1636 }
1640 fPosY += rcSec.Height(); 1637 fPosY += rcSec.Height();
1641 } 1638 }
1642 } 1639 }
1643 return rcRet; 1640 return rcRet;
1644 } 1641 }
1645 FX_INT32 CPDF_VariableText::GetCharWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_W ORD SubWord, FX_INT32 nWordStyle) 1642 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WOR D SubWord, int32_t nWordStyle)
1646 { 1643 {
1647 if (m_pVTProvider) { 1644 if (m_pVTProvider) {
1648 if (SubWord > 0) { 1645 if (SubWord > 0) {
1649 return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); 1646 return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle);
1650 } else { 1647 } else {
1651 return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); 1648 return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle);
1652 } 1649 }
1653 } 1650 }
1654 return 0; 1651 return 0;
1655 } 1652 }
1656 FX_INT32 CPDF_VariableText::GetTypeAscent(FX_INT32 nFontIndex) 1653 int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex)
1657 { 1654 {
1658 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0; 1655 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0;
1659 } 1656 }
1660 FX_INT32 CPDF_VariableText::GetTypeDescent(FX_INT32 nFontIndex) 1657 int32_t CPDF_VariableText::GetTypeDescent(int32_t nFontIndex)
1661 { 1658 {
1662 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0; 1659 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0;
1663 } 1660 }
1664 FX_INT32 CPDF_VariableText::GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_ INT32 nFontIndex) 1661 int32_t CPDF_VariableText::GetWordFontIndex(FX_WORD word, int32_t charset, int32 _t nFontIndex)
1665 { 1662 {
1666 return m_pVTProvider ? m_pVTProvider->GetWordFontIndex(word, charset, nFontI ndex) : -1; 1663 return m_pVTProvider ? m_pVTProvider->GetWordFontIndex(word, charset, nFontI ndex) : -1;
1667 } 1664 }
1668 FX_INT32 CPDF_VariableText::GetDefaultFontIndex() 1665 int32_t CPDF_VariableText::GetDefaultFontIndex()
1669 { 1666 {
1670 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; 1667 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1;
1671 } 1668 }
1672 FX_BOOL CPDF_VariableText::IsLatinWord(FX_WORD word) 1669 FX_BOOL CPDF_VariableText::IsLatinWord(FX_WORD word)
1673 { 1670 {
1674 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : FALSE; 1671 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : FALSE;
1675 } 1672 }
1676 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator() 1673 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator()
1677 { 1674 {
1678 if (!m_pVTIterator) { 1675 if (!m_pVTIterator) {
1679 return m_pVTIterator = FX_NEW CPDF_VariableText_Iterator(this); 1676 return m_pVTIterator = FX_NEW CPDF_VariableText_Iterator(this);
1680 } 1677 }
1681 return m_pVTIterator; 1678 return m_pVTIterator;
1682 } 1679 }
1683 IPDF_VariableText_Provider* CPDF_VariableText::SetProvider(IPDF_VariableText _Provider * pProvider) 1680 IPDF_VariableText_Provider* CPDF_VariableText::SetProvider(IPDF_VariableText _Provider * pProvider)
1684 { 1681 {
1685 IPDF_VariableText_Provider* pOld = m_pVTProvider; 1682 IPDF_VariableText_Provider* pOld = m_pVTProvider;
1686 m_pVTProvider = pProvider; 1683 m_pVTProvider = pProvider;
1687 return pOld; 1684 return pOld;
1688 } 1685 }
1689 CPDF_VariableText_Iterator::CPDF_VariableText_Iterator(CPDF_VariableText * pVT): 1686 CPDF_VariableText_Iterator::CPDF_VariableText_Iterator(CPDF_VariableText * pVT):
1690 m_CurPos(-1, -1, -1), 1687 m_CurPos(-1, -1, -1),
1691 m_pVT(pVT) 1688 m_pVT(pVT)
1692 { 1689 {
1693 } 1690 }
1694 CPDF_VariableText_Iterator::~CPDF_VariableText_Iterator() 1691 CPDF_VariableText_Iterator::~CPDF_VariableText_Iterator()
1695 { 1692 {
1696 } 1693 }
1697 void CPDF_VariableText_Iterator::SetAt(FX_INT32 nWordIndex) 1694 void CPDF_VariableText_Iterator::SetAt(int32_t nWordIndex)
1698 { 1695 {
1699 ASSERT(m_pVT != NULL); 1696 ASSERT(m_pVT != NULL);
1700 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); 1697 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex);
1701 } 1698 }
1702 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) 1699 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place)
1703 { 1700 {
1704 ASSERT(m_pVT != NULL); 1701 ASSERT(m_pVT != NULL);
1705 m_CurPos = place; 1702 m_CurPos = place;
1706 } 1703 }
1707 FX_BOOL CPDF_VariableText_Iterator::NextWord() 1704 FX_BOOL CPDF_VariableText_Iterator::NextWord()
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 if (pSection->m_SecInfo.pSecProps) { 1851 if (pSection->m_SecInfo.pSecProps) {
1855 *pSection->m_SecInfo.pSecProps = section.SecProps; 1852 *pSection->m_SecInfo.pSecProps = section.SecProps;
1856 } 1853 }
1857 if (pSection->m_SecInfo.pWordProps) { 1854 if (pSection->m_SecInfo.pWordProps) {
1858 *pSection->m_SecInfo.pWordProps = section.WordProps; 1855 *pSection->m_SecInfo.pWordProps = section.WordProps;
1859 } 1856 }
1860 return TRUE; 1857 return TRUE;
1861 } 1858 }
1862 return FALSE; 1859 return FALSE;
1863 } 1860 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_viewerPreferences.cpp ('k') | core/src/fpdfdoc/pdf_vt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698