| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/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 Loading... |
| 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) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 150 m_pCharWidth = NULL; | 149 m_pCharWidth = NULL; |
| 151 } | 150 } |
| 152 if (m_pIter != NULL) { | 151 if (m_pIter != NULL) { |
| 153 m_pIter->Release(); | 152 m_pIter->Release(); |
| 154 m_pIter = NULL; | 153 m_pIter = NULL; |
| 155 } | 154 } |
| 156 } | 155 } |
| 157 void CFDE_TxtEdtPage::Release() { | 156 void CFDE_TxtEdtPage::Release() { |
| 158 delete this; | 157 delete this; |
| 159 } | 158 } |
| 160 IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { | 159 CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { |
| 161 return (IFDE_TxtEdtEngine*)m_pEditEngine; | 160 return m_pEditEngine; |
| 162 } | 161 } |
| 163 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { | 162 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { |
| 164 return FDE_VISUALOBJ_Text; | 163 return FDE_VISUALOBJ_Text; |
| 165 } | 164 } |
| 166 FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) { | 165 FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) { |
| 167 return FALSE; | 166 return FALSE; |
| 168 } | 167 } |
| 169 FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj, | 168 FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj, |
| 170 CFX_Matrix& matrix) { | 169 CFX_Matrix& matrix) { |
| 171 return FALSE; | 170 return FALSE; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 347 } |
| 349 RectFArr.Add(piece->rtPiece); | 348 RectFArr.Add(piece->rtPiece); |
| 350 } | 349 } |
| 351 } | 350 } |
| 352 } | 351 } |
| 353 | 352 |
| 354 int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { | 353 int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { |
| 355 if (m_nRefCount < 0) { | 354 if (m_nRefCount < 0) { |
| 356 return -1; | 355 return -1; |
| 357 } | 356 } |
| 358 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); | 357 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); |
| 359 FX_BOOL bBefore; | 358 FX_BOOL bBefore; |
| 360 int32_t nIndex = GetCharIndex(fPoint, bBefore); | 359 int32_t nIndex = GetCharIndex(fPoint, bBefore); |
| 361 if (nIndex == m_pEditEngine->GetTextBufLength()) { | 360 if (nIndex == m_pEditEngine->GetTextBufLength()) { |
| 362 nIndex = m_pEditEngine->GetTextBufLength() - 1; | 361 nIndex = m_pEditEngine->GetTextBufLength() - 1; |
| 363 } | 362 } |
| 364 if (nIndex < 0) { | 363 if (nIndex < 0) { |
| 365 return -1; | 364 return -1; |
| 366 } | 365 } |
| 367 CFX_WordBreak* pIter = new CFX_WordBreak; | 366 CFX_WordBreak* pIter = new CFX_WordBreak; |
| 368 pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); | 367 pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); |
| 369 pIter->SetAt(nIndex); | 368 pIter->SetAt(nIndex); |
| 370 nCount = pIter->GetWordLength(); | 369 nCount = pIter->GetWordLength(); |
| 371 int32_t nRet = pIter->GetWordPos(); | 370 int32_t nRet = pIter->GetWordPos(); |
| 372 pIter->Release(); | 371 pIter->Release(); |
| 373 return nRet; | 372 return nRet; |
| 374 } | 373 } |
| 375 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { | 374 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { |
| 376 return m_bLoaded; | 375 return m_bLoaded; |
| 377 } | 376 } |
| 378 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, | 377 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, |
| 379 IFX_Pause* pPause) { | 378 IFX_Pause* pPause) { |
| 380 if (m_nRefCount > 0) { | 379 if (m_nRefCount > 0) { |
| 381 m_nRefCount++; | 380 m_nRefCount++; |
| 382 return m_nRefCount; | 381 return m_nRefCount; |
| 383 } | 382 } |
| 384 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); | 383 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); |
| 385 const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams(); | 384 const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams(); |
| 386 if (m_pIter != NULL) { | 385 if (m_pIter != NULL) { |
| 387 m_pIter->Release(); | 386 m_pIter->Release(); |
| 388 } | 387 } |
| 389 FX_WCHAR wcAlias = 0; | 388 FX_WCHAR wcAlias = 0; |
| 390 if (pParams->dwMode & FDE_TEXTEDITMODE_Password) { | 389 if (pParams->dwMode & FDE_TEXTEDITMODE_Password) { |
| 391 wcAlias = m_pEditEngine->GetAliasChar(); | 390 wcAlias = m_pEditEngine->GetAliasChar(); |
| 392 } | 391 } |
| 393 m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias); | 392 m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias); |
| 394 CFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak(); | 393 CFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 ptF.x = rtF.left; | 636 ptF.x = rtF.left; |
| 638 } else if (ptF.x >= rtF.right()) { | 637 } else if (ptF.x >= rtF.right()) { |
| 639 ptF.x = rtF.right() - fTolerance; | 638 ptF.x = rtF.right() - fTolerance; |
| 640 } | 639 } |
| 641 if (ptF.y < rtF.top) { | 640 if (ptF.y < rtF.top) { |
| 642 ptF.y = rtF.top; | 641 ptF.y = rtF.top; |
| 643 } else if (ptF.y >= rtF.bottom()) { | 642 } else if (ptF.y >= rtF.bottom()) { |
| 644 ptF.y = rtF.bottom() - fTolerance; | 643 ptF.y = rtF.bottom() - fTolerance; |
| 645 } | 644 } |
| 646 } | 645 } |
| OLD | NEW |