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 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (hText == NULL) { | 69 if (hText == NULL) { |
70 return 0; | 70 return 0; |
71 } | 71 } |
72 FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; | 72 FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; |
73 int32_t nLength = pPiece->nCount; | 73 int32_t nLength = pPiece->nCount; |
74 if (nLength < 1) { | 74 if (nLength < 1) { |
75 return 0; | 75 return 0; |
76 } | 76 } |
77 CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine()); | 77 CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine()); |
78 const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); | 78 const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); |
79 IFX_TxtBreak* pBreak = pEngine->GetTextBreak(); | 79 CFX_TxtBreak* pBreak = pEngine->GetTextBreak(); |
80 uint32_t dwLayoutStyle = pBreak->GetLayoutStyles(); | 80 uint32_t dwLayoutStyle = pBreak->GetLayoutStyles(); |
81 FX_TXTRUN tr; | 81 FX_TXTRUN tr; |
82 tr.pAccess = m_pPage; | 82 tr.pAccess = m_pPage; |
83 tr.pIdentity = (void*)hText; | 83 tr.pIdentity = (void*)hText; |
84 tr.pStr = NULL; | 84 tr.pStr = NULL; |
85 tr.pWidths = NULL; | 85 tr.pWidths = NULL; |
86 tr.iLength = nLength; | 86 tr.iLength = nLength; |
87 tr.pFont = pTextParams->pFont; | 87 tr.pFont = pTextParams->pFont; |
88 tr.fFontSize = pTextParams->fFontSize; | 88 tr.fFontSize = pTextParams->fFontSize; |
89 tr.dwStyles = dwLayoutStyle; | 89 tr.dwStyles = dwLayoutStyle; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 361 } |
362 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); | 362 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); |
363 FX_BOOL bBefore; | 363 FX_BOOL bBefore; |
364 int32_t nIndex = GetCharIndex(fPoint, bBefore); | 364 int32_t nIndex = GetCharIndex(fPoint, bBefore); |
365 if (nIndex == m_pEditEngine->GetTextBufLength()) { | 365 if (nIndex == m_pEditEngine->GetTextBufLength()) { |
366 nIndex = m_pEditEngine->GetTextBufLength() - 1; | 366 nIndex = m_pEditEngine->GetTextBufLength() - 1; |
367 } | 367 } |
368 if (nIndex < 0) { | 368 if (nIndex < 0) { |
369 return -1; | 369 return -1; |
370 } | 370 } |
371 IFX_WordBreak* pIter = FX_WordBreak_Create(); | 371 CFX_WordBreak* pIter = new CFX_WordBreak; |
372 pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); | 372 pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); |
373 pIter->SetAt(nIndex); | 373 pIter->SetAt(nIndex); |
374 nCount = pIter->GetWordLength(); | 374 nCount = pIter->GetWordLength(); |
375 int32_t nRet = pIter->GetWordPos(); | 375 int32_t nRet = pIter->GetWordPos(); |
376 pIter->Release(); | 376 pIter->Release(); |
377 return nRet; | 377 return nRet; |
378 } | 378 } |
379 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { | 379 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { |
380 return m_bLoaded; | 380 return m_bLoaded; |
381 } | 381 } |
382 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, | 382 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, |
383 IFX_Pause* pPause) { | 383 IFX_Pause* pPause) { |
384 if (m_nRefCount > 0) { | 384 if (m_nRefCount > 0) { |
385 m_nRefCount++; | 385 m_nRefCount++; |
386 return m_nRefCount; | 386 return m_nRefCount; |
387 } | 387 } |
388 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); | 388 IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); |
389 const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams(); | 389 const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams(); |
390 if (m_pIter != NULL) { | 390 if (m_pIter != NULL) { |
391 m_pIter->Release(); | 391 m_pIter->Release(); |
392 } | 392 } |
393 FX_WCHAR wcAlias = 0; | 393 FX_WCHAR wcAlias = 0; |
394 if (pParams->dwMode & FDE_TEXTEDITMODE_Password) { | 394 if (pParams->dwMode & FDE_TEXTEDITMODE_Password) { |
395 wcAlias = m_pEditEngine->GetAliasChar(); | 395 wcAlias = m_pEditEngine->GetAliasChar(); |
396 } | 396 } |
397 m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias); | 397 m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias); |
398 IFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak(); | 398 CFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak(); |
399 pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 399 pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
400 pBreak->ClearBreakPieces(); | 400 pBreak->ClearBreakPieces(); |
401 int32_t nPageLineCount = m_pEditEngine->GetPageLineCount(); | 401 int32_t nPageLineCount = m_pEditEngine->GetPageLineCount(); |
402 int32_t nStartLine = nPageLineCount * m_nPageIndex; | 402 int32_t nStartLine = nPageLineCount * m_nPageIndex; |
403 int32_t nEndLine = std::min((nStartLine + nPageLineCount - 1), | 403 int32_t nEndLine = std::min((nStartLine + nPageLineCount - 1), |
404 (m_pEditEngine->GetLineCount() - 1)); | 404 (m_pEditEngine->GetLineCount() - 1)); |
405 int32_t nPageStart, nPageEnd, nTemp, nBgnParag, nStartLineInParag, nEndParag, | 405 int32_t nPageStart, nPageEnd, nTemp, nBgnParag, nStartLineInParag, nEndParag, |
406 nEndLineInParag; | 406 nEndLineInParag; |
407 nBgnParag = m_pEditEngine->Line2Parag(0, 0, nStartLine, nStartLineInParag); | 407 nBgnParag = m_pEditEngine->Line2Parag(0, 0, nStartLine, nStartLineInParag); |
408 m_pBgnParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nBgnParag); | 408 m_pBgnParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nBgnParag); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 ptF.x = rtF.left; | 641 ptF.x = rtF.left; |
642 } else if (ptF.x >= rtF.right()) { | 642 } else if (ptF.x >= rtF.right()) { |
643 ptF.x = rtF.right() - fTolerance; | 643 ptF.x = rtF.right() - fTolerance; |
644 } | 644 } |
645 if (ptF.y < rtF.top) { | 645 if (ptF.y < rtF.top) { |
646 ptF.y = rtF.top; | 646 ptF.y = rtF.top; |
647 } else if (ptF.y >= rtF.bottom()) { | 647 } else if (ptF.y >= rtF.bottom()) { |
648 ptF.y = rtF.bottom() - fTolerance; | 648 ptF.y = rtF.bottom() - fTolerance; |
649 } | 649 } |
650 } | 650 } |
OLD | NEW |