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

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

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: Created 4 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 | « xfa/fde/cfde_txtedtengine.cpp ('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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 pPiece->rtPiece.top > ptF.y)) { 131 pPiece->rtPiece.top > ptF.y)) {
132 nEnd = i - 1; 132 nEnd = i - 1;
133 break; 133 break;
134 } else { 134 } else {
135 rtLine.Union(pPiece->rtPiece); 135 rtLine.Union(pPiece->rtPiece);
136 } 136 }
137 } 137 }
138 } 138 }
139 NormalizePt2Rect(ptF, rtLine, kTolerance); 139 NormalizePt2Rect(ptF, rtLine, kTolerance);
140 int32_t nCaret = 0; 140 int32_t nCaret = 0;
141 FDE_TEXTEDITPIECE* pPiece = NULL; 141 FDE_TEXTEDITPIECE* pPiece = nullptr;
142 for (i = nBgn; i <= nEnd; i++) { 142 for (i = nBgn; i <= nEnd; i++) {
143 pPiece = m_PieceMassArr.GetPtrAt(i); 143 pPiece = m_PieceMassArr.GetPtrAt(i);
144 nCaret = m_nPageStart + pPiece->nStart; 144 nCaret = m_nPageStart + pPiece->nStart;
145 if (pPiece->rtPiece.Contains(ptF)) { 145 if (pPiece->rtPiece.Contains(ptF)) {
146 CFX_RectFArray rectArr; 146 CFX_RectFArray rectArr;
147 m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr); 147 m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr);
148 int32_t nRtCount = rectArr.GetSize(); 148 int32_t nRtCount = rectArr.GetSize();
149 for (int32_t j = 0; j < nRtCount; j++) { 149 for (int32_t j = 0; j < nRtCount; j++) {
150 if (rectArr[j].Contains(ptF)) { 150 if (rectArr[j].Contains(ptF)) {
151 nCaret = m_nPageStart + pPiece->nStart + j; 151 nCaret = m_nPageStart + pPiece->nStart + j;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 int32_t CFDE_TxtEdtPage::GetCharCount() const { 187 int32_t CFDE_TxtEdtPage::GetCharCount() const {
188 return m_nCharCount; 188 return m_nCharCount;
189 } 189 }
190 190
191 int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip, 191 int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
192 FXTEXT_CHARPOS*& pCharPos, 192 FXTEXT_CHARPOS*& pCharPos,
193 CFX_RectF* pBBox) const { 193 CFX_RectF* pBBox) const {
194 pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount); 194 pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount);
195 int32_t nCharPosCount = 0; 195 int32_t nCharPosCount = 0;
196 FDE_HVISUALOBJ hVisualObj = NULL; 196 FDE_HVISUALOBJ hVisualObj = nullptr;
197 int32_t nVisualObjCount = m_PieceMassArr.GetSize(); 197 int32_t nVisualObjCount = m_PieceMassArr.GetSize();
198 FXTEXT_CHARPOS* pos = pCharPos; 198 FXTEXT_CHARPOS* pos = pCharPos;
199 CFX_RectF rtObj; 199 CFX_RectF rtObj;
200 for (int32_t i = 0; i < nVisualObjCount; i++) { 200 for (int32_t i = 0; i < nVisualObjCount; i++) {
201 hVisualObj = (FDE_HVISUALOBJ)m_PieceMassArr.GetPtrAt(i); 201 hVisualObj = (FDE_HVISUALOBJ)m_PieceMassArr.GetPtrAt(i);
202 m_pTextSet->GetRect(hVisualObj, rtObj); 202 m_pTextSet->GetRect(hVisualObj, rtObj);
203 if (!rtClip.IntersectWith(rtObj)) { 203 if (!rtClip.IntersectWith(rtObj)) {
204 continue; 204 continue;
205 } 205 }
206 int32_t nCount = m_pTextSet->GetDisplayPos(hVisualObj, pos, FALSE); 206 int32_t nCount = m_pTextSet->GetDisplayPos(hVisualObj, pos, FALSE);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 FX_BOOL bVertial = pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical; 316 FX_BOOL bVertial = pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical;
317 FX_BOOL bLineReserve = 317 FX_BOOL bLineReserve =
318 pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; 318 pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve;
319 FX_FLOAT fLineStart = 319 FX_FLOAT fLineStart =
320 bVertial 320 bVertial
321 ? (bLineReserve ? (pParams->fPlateWidth - pParams->fLineSpace) : 0.0f) 321 ? (bLineReserve ? (pParams->fPlateWidth - pParams->fLineSpace) : 0.0f)
322 : 0.0f; 322 : 0.0f;
323 FX_FLOAT fLineStep = 323 FX_FLOAT fLineStep =
324 (bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace; 324 (bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace;
325 FX_FLOAT fLinePos = fLineStart; 325 FX_FLOAT fLinePos = fLineStart;
326 if (m_pTextSet == NULL) { 326 if (!m_pTextSet)
327 m_pTextSet = new CFDE_TxtEdtTextSet(this); 327 m_pTextSet = new CFDE_TxtEdtTextSet(this);
328 }
329 m_PieceMassArr.RemoveAll(TRUE); 328 m_PieceMassArr.RemoveAll(TRUE);
330 uint32_t dwBreakStatus = FX_TXTBREAK_None; 329 uint32_t dwBreakStatus = FX_TXTBREAK_None;
331 int32_t nPieceStart = 0; 330 int32_t nPieceStart = 0;
332 if (m_pCharWidth != NULL) { 331 delete[] m_pCharWidth;
333 delete[] m_pCharWidth;
334 }
335 m_pCharWidth = new int32_t[nPageEnd - nPageStart + 1]; 332 m_pCharWidth = new int32_t[nPageEnd - nPageStart + 1];
336 pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); 333 pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
337 pBreak->ClearBreakPieces(); 334 pBreak->ClearBreakPieces();
338 m_nPageStart = nPageStart; 335 m_nPageStart = nPageStart;
339 m_nCharCount = nPageEnd - nPageStart + 1; 336 m_nCharCount = nPageEnd - nPageStart + 1;
340 FX_BOOL bReload = FALSE; 337 FX_BOOL bReload = FALSE;
341 FX_FLOAT fDefCharWidth = 0; 338 FX_FLOAT fDefCharWidth = 0;
342 std::unique_ptr<IFX_CharIter> pIter(m_pIter->Clone()); 339 std::unique_ptr<IFX_CharIter> pIter(m_pIter->Clone());
343 pIter->SetAt(nPageStart); 340 pIter->SetAt(nPageStart);
344 m_pIter->SetAt(nPageStart); 341 m_pIter->SetAt(nPageStart);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 476 }
480 m_pIter.reset(); 477 m_pIter.reset();
481 } 478 }
482 479
483 const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() { 480 const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() {
484 return m_rtPageContents; 481 return m_rtPageContents;
485 } 482 }
486 483
487 FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) { 484 FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) {
488 if (m_PieceMassArr.GetSize() < 1) { 485 if (m_PieceMassArr.GetSize() < 1) {
489 return NULL; 486 return nullptr;
490 } 487 }
491 return (FX_POSITION)1; 488 return (FX_POSITION)1;
492 } 489 }
493 490
494 FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas, 491 FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas,
495 FX_POSITION& pos, 492 FX_POSITION& pos,
496 IFDE_VisualSet*& pVisualSet) { 493 IFDE_VisualSet*& pVisualSet) {
497 if (m_pTextSet == NULL) { 494 if (!m_pTextSet) {
498 pos = NULL; 495 pos = nullptr;
499 return NULL; 496 return nullptr;
500 } 497 }
501 int32_t nPos = (int32_t)(uintptr_t)pos; 498 int32_t nPos = (int32_t)(uintptr_t)pos;
502 pVisualSet = m_pTextSet; 499 pVisualSet = m_pTextSet;
503 if (nPos + 1 > m_PieceMassArr.GetSize()) { 500 if (nPos + 1 > m_PieceMassArr.GetSize()) {
504 pos = NULL; 501 pos = nullptr;
505 } else { 502 } else {
506 pos = (FX_POSITION)(uintptr_t)(nPos + 1); 503 pos = (FX_POSITION)(uintptr_t)(nPos + 1);
507 } 504 }
508 return (FDE_HVISUALOBJ)(m_PieceMassArr.GetPtrAt(nPos - 1)); 505 return (FDE_HVISUALOBJ)(m_PieceMassArr.GetPtrAt(nPos - 1));
509 } 506 }
510 507
511 FDE_HVISUALOBJ CFDE_TxtEdtPage::GetParentCanvas(FDE_HVISUALOBJ hCanvas, 508 FDE_HVISUALOBJ CFDE_TxtEdtPage::GetParentCanvas(FDE_HVISUALOBJ hCanvas,
512 IFDE_VisualSet*& pVisualSet) { 509 IFDE_VisualSet*& pVisualSet) {
513 return NULL; 510 return nullptr;
514 } 511 }
515 512
516 FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const { 513 FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const {
517 int32_t nIndex = 514 int32_t nIndex =
518 m_nPageStart + ((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index; 515 m_nPageStart + ((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index;
519 if (nIndex != m_pIter->GetAt()) { 516 if (nIndex != m_pIter->GetAt()) {
520 m_pIter->SetAt(nIndex); 517 m_pIter->SetAt(nIndex);
521 } 518 }
522 FX_WCHAR wChar = m_pIter->GetChar(); 519 FX_WCHAR wChar = m_pIter->GetChar();
523 m_pIter->Next(); 520 m_pIter->Next();
(...skipping 16 matching lines...) Expand all
540 ptF.x = rtF.left; 537 ptF.x = rtF.left;
541 } else if (ptF.x >= rtF.right()) { 538 } else if (ptF.x >= rtF.right()) {
542 ptF.x = rtF.right() - fTolerance; 539 ptF.x = rtF.right() - fTolerance;
543 } 540 }
544 if (ptF.y < rtF.top) { 541 if (ptF.y < rtF.top) {
545 ptF.y = rtF.top; 542 ptF.y = rtF.top;
546 } else if (ptF.y >= rtF.bottom()) { 543 } else if (ptF.y >= rtF.bottom()) {
547 ptF.y = rtF.bottom() - fTolerance; 544 ptF.y = rtF.bottom() - fTolerance;
548 } 545 }
549 } 546 }
OLDNEW
« no previous file with comments | « xfa/fde/cfde_txtedtengine.cpp ('k') | xfa/fde/cfde_txtedtparag.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698