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

Side by Side Diff: xfa/fee/fde_txtedtpage.cpp

Issue 1927973003: Remove IFDE_TxtEdt interfaces where possible. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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/fee/fde_txtedtpage.h ('k') | xfa/fee/fde_txtedtparag.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 "xfa/fee/fde_txtedtpage.h" 7 #include "xfa/fee/fde_txtedtpage.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "xfa/fee/fde_txtedtbuf.h" 11 #include "xfa/fee/fde_txtedtbuf.h"
12 #include "xfa/fee/fde_txtedtengine.h" 12 #include "xfa/fee/fde_txtedtengine.h"
13 #include "xfa/fee/fde_txtedtparag.h" 13 #include "xfa/fee/fde_txtedtparag.h"
14 #include "xfa/fee/fx_wordbreak/fx_wordbreak.h" 14 #include "xfa/fee/fx_wordbreak/fx_wordbreak.h"
15 #include "xfa/fee/ifde_txtedtbuf.h"
16 #include "xfa/fee/ifde_txtedtengine.h" 15 #include "xfa/fee/ifde_txtedtengine.h"
17 #include "xfa/fee/ifde_txtedtpage.h" 16 #include "xfa/fee/ifde_txtedtpage.h"
18 17
19 #define FDE_TXTEDT_TOLERANCE 0.1f 18 #define FDE_TXTEDT_TOLERANCE 0.1f
20 19
21 IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(IFDE_TxtEdtEngine* pEngine, 20 IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine,
22 int32_t nIndex) { 21 int32_t nIndex) {
23 return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex); 22 return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex);
24 } 23 }
25 CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage) 24 CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage)
26 : m_pPage(pPage) {} 25 : m_pPage(pPage) {}
27 CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {} 26 CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {}
28 FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() { 27 FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() {
29 return FDE_VISUALOBJ_Text; 28 return FDE_VISUALOBJ_Text;
30 } 29 }
31 FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj, 30 FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 tr.iLength = nLength; 114 tr.iLength = nLength;
116 tr.pFont = pTextParams->pFont; 115 tr.pFont = pTextParams->pFont;
117 tr.fFontSize = pTextParams->fFontSize; 116 tr.fFontSize = pTextParams->fFontSize;
118 tr.dwStyles = dwLayoutStyle; 117 tr.dwStyles = dwLayoutStyle;
119 tr.iCharRotation = pTextParams->nCharRotation; 118 tr.iCharRotation = pTextParams->nCharRotation;
120 tr.dwCharStyles = pPiece->dwCharStyles; 119 tr.dwCharStyles = pPiece->dwCharStyles;
121 tr.pRect = &(pPiece->rtPiece); 120 tr.pRect = &(pPiece->rtPiece);
122 tr.wLineBreakChar = pTextParams->wLineBreakChar; 121 tr.wLineBreakChar = pTextParams->wLineBreakChar;
123 return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox); 122 return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox);
124 } 123 }
125 CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) 124 CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
126 : m_pIter(nullptr), 125 : m_pIter(nullptr),
127 m_pTextSet(nullptr), 126 m_pTextSet(nullptr),
128 m_pBgnParag(nullptr), 127 m_pBgnParag(nullptr),
129 m_pEndParag(nullptr), 128 m_pEndParag(nullptr),
130 m_nRefCount(0), 129 m_nRefCount(0),
131 m_nPageStart(-1), 130 m_nPageStart(-1),
132 m_nCharCount(0), 131 m_nCharCount(0),
133 m_nPageIndex(nPageIndex), 132 m_nPageIndex(nPageIndex),
134 m_bLoaded(FALSE), 133 m_bLoaded(FALSE),
135 m_pCharWidth(nullptr) { 134 m_pCharWidth(nullptr) {
136 FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF)); 135 FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF));
137 FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); 136 FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF));
138 FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); 137 FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF));
139 FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF)); 138 FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF));
140 m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine; 139 m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine;
141 } 140 }
142 141
143 CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { 142 CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
144 m_PieceMassArr.RemoveAll(TRUE); 143 m_PieceMassArr.RemoveAll(TRUE);
145 delete m_pTextSet; 144 delete m_pTextSet;
146 delete[] m_pCharWidth; 145 delete[] m_pCharWidth;
147 if (m_pIter) 146 if (m_pIter)
148 m_pIter->Release(); 147 m_pIter->Release();
149 } 148 }
150 149
151 void CFDE_TxtEdtPage::Release() { 150 void CFDE_TxtEdtPage::Release() {
152 delete this; 151 delete this;
153 } 152 }
154 IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { 153 CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
155 return (IFDE_TxtEdtEngine*)m_pEditEngine; 154 return m_pEditEngine;
156 } 155 }
157 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { 156 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() {
158 return FDE_VISUALOBJ_Text; 157 return FDE_VISUALOBJ_Text;
159 } 158 }
160 FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) { 159 FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) {
161 return FALSE; 160 return FALSE;
162 } 161 }
163 FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj, 162 FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj,
164 CFX_Matrix& matrix) { 163 CFX_Matrix& matrix) {
165 return FALSE; 164 return FALSE;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 341 }
343 RectFArr.Add(piece->rtPiece); 342 RectFArr.Add(piece->rtPiece);
344 } 343 }
345 } 344 }
346 } 345 }
347 346
348 int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { 347 int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
349 if (m_nRefCount < 0) { 348 if (m_nRefCount < 0) {
350 return -1; 349 return -1;
351 } 350 }
352 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); 351 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
353 FX_BOOL bBefore; 352 FX_BOOL bBefore;
354 int32_t nIndex = GetCharIndex(fPoint, bBefore); 353 int32_t nIndex = GetCharIndex(fPoint, bBefore);
355 if (nIndex == m_pEditEngine->GetTextBufLength()) { 354 if (nIndex == m_pEditEngine->GetTextBufLength()) {
356 nIndex = m_pEditEngine->GetTextBufLength() - 1; 355 nIndex = m_pEditEngine->GetTextBufLength() - 1;
357 } 356 }
358 if (nIndex < 0) { 357 if (nIndex < 0) {
359 return -1; 358 return -1;
360 } 359 }
361 CFX_WordBreak* pIter = new CFX_WordBreak; 360 CFX_WordBreak* pIter = new CFX_WordBreak;
362 pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); 361 pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf));
363 pIter->SetAt(nIndex); 362 pIter->SetAt(nIndex);
364 nCount = pIter->GetWordLength(); 363 nCount = pIter->GetWordLength();
365 int32_t nRet = pIter->GetWordPos(); 364 int32_t nRet = pIter->GetWordPos();
366 pIter->Release(); 365 pIter->Release();
367 return nRet; 366 return nRet;
368 } 367 }
369 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { 368 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) {
370 return m_bLoaded; 369 return m_bLoaded;
371 } 370 }
372 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, 371 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
373 IFX_Pause* pPause) { 372 IFX_Pause* pPause) {
374 if (m_nRefCount > 0) { 373 if (m_nRefCount > 0) {
375 m_nRefCount++; 374 m_nRefCount++;
376 return m_nRefCount; 375 return m_nRefCount;
377 } 376 }
378 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); 377 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
379 const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams(); 378 const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams();
380 if (m_pIter != NULL) { 379 if (m_pIter != NULL) {
381 m_pIter->Release(); 380 m_pIter->Release();
382 } 381 }
383 FX_WCHAR wcAlias = 0; 382 FX_WCHAR wcAlias = 0;
384 if (pParams->dwMode & FDE_TEXTEDITMODE_Password) { 383 if (pParams->dwMode & FDE_TEXTEDITMODE_Password) {
385 wcAlias = m_pEditEngine->GetAliasChar(); 384 wcAlias = m_pEditEngine->GetAliasChar();
386 } 385 }
387 m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias); 386 m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias);
388 CFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak(); 387 CFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 ptF.x = rtF.left; 626 ptF.x = rtF.left;
628 } else if (ptF.x >= rtF.right()) { 627 } else if (ptF.x >= rtF.right()) {
629 ptF.x = rtF.right() - fTolerance; 628 ptF.x = rtF.right() - fTolerance;
630 } 629 }
631 if (ptF.y < rtF.top) { 630 if (ptF.y < rtF.top) {
632 ptF.y = rtF.top; 631 ptF.y = rtF.top;
633 } else if (ptF.y >= rtF.bottom()) { 632 } else if (ptF.y >= rtF.bottom()) {
634 ptF.y = rtF.bottom() - fTolerance; 633 ptF.y = rtF.bottom() - fTolerance;
635 } 634 }
636 } 635 }
OLDNEW
« no previous file with comments | « xfa/fee/fde_txtedtpage.h ('k') | xfa/fee/fde_txtedtparag.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698