summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-16 16:36:31 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-16 21:39:28 +0000
commita364729be3725adbc9689c1c8c23902df102243b (patch)
tree4d97b4e0a50145996f5b7b487a48c499e67eff82
parenta016857bcee1a09e67bd34e895ef639a3946fa91 (diff)
downloadpdfium-chromium/3188.tar.xz
Move some CFDE_TxtEdt* methods to the headerschromium/3188
This CL moves several methods from the CFDE_TxtEdt* classes from the .cpp to .h files. As well, the GetCaretRect method is updated to return the rect instead of using an out param. Change-Id: I1288701f47d9ac1c413fbf06627f20b295b18b86 Reviewed-on: https://pdfium-review.googlesource.com/11270 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r--xfa/fde/cfde_txtedtbuf.cpp12
-rw-r--r--xfa/fde/cfde_txtedtbuf.h6
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp83
-rw-r--r--xfa/fde/cfde_txtedtengine.h54
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp28
-rw-r--r--xfa/fde/cfde_txtedtpage.h14
-rw-r--r--xfa/fde/cfde_txtedttextset.cpp4
-rw-r--r--xfa/fde/cfde_txtedttextset.h4
-rw-r--r--xfa/fwl/cfwl_edit.cpp6
9 files changed, 47 insertions, 164 deletions
diff --git a/xfa/fde/cfde_txtedtbuf.cpp b/xfa/fde/cfde_txtedtbuf.cpp
index d0f41d8b9d..1691cdaceb 100644
--- a/xfa/fde/cfde_txtedtbuf.cpp
+++ b/xfa/fde/cfde_txtedtbuf.cpp
@@ -24,14 +24,6 @@ CFDE_TxtEdtBuf::CFDE_TxtEdtBuf() : m_chunkSize(kDefaultChunkSize), m_nTotal(0) {
CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() {}
-int32_t CFDE_TxtEdtBuf::GetChunkSize() const {
- return m_chunkSize;
-}
-
-int32_t CFDE_TxtEdtBuf::GetTextLength() const {
- return m_nTotal;
-}
-
void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
ASSERT(!wsText.IsEmpty());
@@ -61,10 +53,6 @@ void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
m_nTotal = nTextLength;
}
-CFX_WideString CFDE_TxtEdtBuf::GetText() const {
- return GetRange(0, m_nTotal);
-}
-
wchar_t CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
ASSERT(nIndex >= 0 && nIndex < GetTextLength());
diff --git a/xfa/fde/cfde_txtedtbuf.h b/xfa/fde/cfde_txtedtbuf.h
index b500a9871e..3f1ad28c4f 100644
--- a/xfa/fde/cfde_txtedtbuf.h
+++ b/xfa/fde/cfde_txtedtbuf.h
@@ -42,11 +42,11 @@ class CFDE_TxtEdtBuf {
CFDE_TxtEdtBuf();
~CFDE_TxtEdtBuf();
- int32_t GetChunkSize() const;
- int32_t GetTextLength() const;
+ int32_t GetChunkSize() const { return m_chunkSize; }
+ int32_t GetTextLength() const { return m_nTotal; }
void SetText(const CFX_WideString& wsText);
- CFX_WideString GetText() const;
+ CFX_WideString GetText() const { return GetRange(0, m_nTotal); }
wchar_t GetCharByIndex(int32_t nIndex) const;
CFX_WideString GetRange(int32_t nBegin, int32_t nCount) const;
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 063c730b1f..e2cfaf653d 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -191,17 +191,6 @@ void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
UpdateTxtBreak();
}
-FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() {
- return &m_Param;
-}
-
-int32_t CFDE_TxtEdtEngine::CountPages() const {
- if (m_nLineCount == 0) {
- return 0;
- }
- return ((m_nLineCount - 1) / m_nPageLineCount) + 1;
-}
-
CFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) {
if (!pdfium::IndexInBounds(m_PagePtrArray, nIndex))
return nullptr;
@@ -257,10 +246,6 @@ void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
RebuildParagraphs();
}
-int32_t CFDE_TxtEdtEngine::GetTextLength() const {
- return GetTextBufLength();
-}
-
CFX_WideString CFDE_TxtEdtEngine::GetText(int32_t nStart,
int32_t nCount) const {
int32_t nTextBufLength = GetTextBufLength();
@@ -276,18 +261,6 @@ void CFDE_TxtEdtEngine::ClearText() {
DeleteRange(0, GetTextBufLength());
}
-int32_t CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret) const {
- rtCaret = m_rtCaret;
- return m_nCaret;
-}
-
-int32_t CFDE_TxtEdtEngine::GetCaretPos() const {
- if (IsLocked())
- return 0;
-
- return m_nCaret + (m_bBefore ? 0 : 1);
-}
-
int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, bool bBefore) {
if (IsLocked())
return 0;
@@ -380,10 +353,6 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
return m_nCaret;
}
-bool CFDE_TxtEdtEngine::IsLocked() const {
- return m_bLock;
-}
-
int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
const wchar_t* lpText,
int32_t nLength) {
@@ -575,14 +544,6 @@ int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
-void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) {
- m_nLimit = nLimit;
-}
-
-void CFDE_TxtEdtEngine::SetAliasChar(wchar_t wcAlias) {
- m_wcAliasChar = wcAlias;
-}
-
void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) {
int32_t nRangeCount = pdfium::CollectionSize<int32_t>(m_SelRangePtrArr);
for (int32_t i = 0; i < nRangeCount; i++) {
@@ -661,10 +622,6 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
m_Param.pEventSink->OnSelChanged();
}
-int32_t CFDE_TxtEdtEngine::CountSelRanges() const {
- return pdfium::CollectionSize<int32_t>(m_SelRangePtrArr);
-}
-
int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t* nStart) const {
if (nStart)
*nStart = m_SelRangePtrArr[nIndex]->nStart;
@@ -705,34 +662,6 @@ void CFDE_TxtEdtEngine::Layout() {
m_rtCaret = CFX_RectF(0, 0, 1, m_Param.fFontSize);
}
-CFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const {
- return m_pTxtBuf.get();
-}
-
-int32_t CFDE_TxtEdtEngine::GetTextBufLength() const {
- return m_pTxtBuf->GetTextLength() - 1;
-}
-
-CFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const {
- return m_pTextBreak.get();
-}
-
-int32_t CFDE_TxtEdtEngine::GetLineCount() const {
- return m_nLineCount;
-}
-
-int32_t CFDE_TxtEdtEngine::GetPageLineCount() const {
- return m_nPageLineCount;
-}
-
-int32_t CFDE_TxtEdtEngine::CountParags() const {
- return pdfium::CollectionSize<int32_t>(m_ParagPtrArray);
-}
-
-CFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const {
- return m_ParagPtrArray[nParagIndex].get();
-}
-
int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
int32_t nStartLineofParag,
int32_t nLineIndex,
@@ -972,14 +901,6 @@ void CFDE_TxtEdtEngine::RebuildParagraphs() {
} while (pIter->Next());
}
-void CFDE_TxtEdtEngine::RemoveAllParags() {
- m_ParagPtrArray.clear();
-}
-
-void CFDE_TxtEdtEngine::RemoveAllPages() {
- m_PagePtrArray.clear();
-}
-
void CFDE_TxtEdtEngine::UpdateLineCounts() {
if (m_ParagPtrArray.empty())
return;
@@ -1429,10 +1350,6 @@ void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) {
m_Param.pEventSink->OnPageUnload(m_nCaretPage);
}
-bool CFDE_TxtEdtEngine::IsSelect() {
- return !m_SelRangePtrArr.empty();
-}
-
void CFDE_TxtEdtEngine::DeleteSelect() {
int32_t nCountRange = CountSelRanges();
if (nCountRange <= 0)
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index 4d3490a9f4..56cf2edb4a 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -14,10 +14,10 @@
#include "core/fxcrt/cfx_seekablestreamproxy.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/fx_dib.h"
+#include "xfa/fde/cfde_txtedtbuf.h"
+#include "xfa/fde/cfde_txtedtpage.h"
+#include "xfa/fde/cfde_txtedtparag.h"
-class CFDE_TxtEdtBuf;
-class CFDE_TxtEdtPage;
-class CFDE_TxtEdtParag;
class CFGAS_GEFont;
class CFWL_Edit;
class CFX_TxtBreak;
@@ -96,22 +96,26 @@ class CFDE_TxtEdtEngine {
~CFDE_TxtEdtEngine();
void SetEditParams(const FDE_TXTEDTPARAMS& params);
- FDE_TXTEDTPARAMS* GetEditParams();
+ FDE_TXTEDTPARAMS* GetEditParams() { return &m_Param; }
- int32_t CountPages() const;
+ int32_t CountPages() const {
+ return m_nLineCount == 0 ? 0 : ((m_nLineCount - 1) / m_nPageLineCount) + 1;
+ }
CFDE_TxtEdtPage* GetPage(int32_t nIndex);
void SetTextByStream(const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream);
void SetText(const CFX_WideString& wsText);
- int32_t GetTextLength() const;
+ int32_t GetTextLength() const { return GetTextBufLength(); }
CFX_WideString GetText(int32_t nStart, int32_t nCount) const;
void ClearText();
- int32_t GetCaretRect(CFX_RectF& rtCaret) const;
- int32_t GetCaretPos() const;
+ CFX_RectF GetCaretRect() const { return m_rtCaret; }
+ int32_t GetCaretPos() const {
+ return IsLocked() ? 0 : m_nCaret + (m_bBefore ? 0 : 1);
+ }
int32_t SetCaretPos(int32_t nIndex, bool bBefore);
int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, bool bShift, bool bCtrl);
- bool IsLocked() const;
+ bool IsLocked() const { return m_bLock; }
int32_t Insert(int32_t nStart, const wchar_t* lpText, int32_t nLength);
int32_t Delete(int32_t nStart, bool bBackspace);
@@ -120,14 +124,16 @@ class CFDE_TxtEdtEngine {
int32_t nLength,
const CFX_WideString& wsReplace);
- void SetLimit(int32_t nLimit);
+ void SetLimit(int32_t nLimit) { m_nLimit = nLimit; }
int32_t GetLimit() const { return m_nLimit; }
- void SetAliasChar(wchar_t wcAlias);
+ void SetAliasChar(wchar_t wcAlias) { m_wcAliasChar = wcAlias; }
void RemoveSelRange(int32_t nStart, int32_t nCount);
void AddSelRange(int32_t nStart, int32_t nCount);
- int32_t CountSelRanges() const;
+ int32_t CountSelRanges() const {
+ return pdfium::CollectionSize<int32_t>(m_SelRangePtrArr);
+ }
int32_t GetSelRange(int32_t nIndex, int32_t* nStart) const;
void ClearSelection();
@@ -136,13 +142,17 @@ class CFDE_TxtEdtEngine {
void Layout();
- int32_t CountParags() const;
- CFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const;
- CFDE_TxtEdtBuf* GetTextBuf() const;
- int32_t GetTextBufLength() const;
- CFX_TxtBreak* GetTextBreak() const;
- int32_t GetLineCount() const;
- int32_t GetPageLineCount() const;
+ int32_t CountParags() const {
+ return pdfium::CollectionSize<int32_t>(m_ParagPtrArray);
+ }
+ CFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const {
+ return m_ParagPtrArray[nParagIndex].get();
+ }
+ CFDE_TxtEdtBuf* GetTextBuf() const { return m_pTxtBuf.get(); }
+ int32_t GetTextBufLength() const { return m_pTxtBuf->GetTextLength() - 1; }
+ CFX_TxtBreak* GetTextBreak() const { return m_pTextBreak.get(); }
+ int32_t GetLineCount() const { return m_nLineCount; }
+ int32_t GetPageLineCount() const { return m_nPageLineCount; }
int32_t Line2Parag(int32_t nStartParag,
int32_t nStartLineofParag,
@@ -150,7 +160,7 @@ class CFDE_TxtEdtEngine {
int32_t& nStartLine) const;
wchar_t GetAliasChar() const { return m_wcAliasChar; }
- bool IsSelect();
+ bool IsSelect() const { return !m_SelRangePtrArr.empty(); }
void Inner_DeleteRange(int32_t nStart, int32_t nCount);
void Inner_Insert(int32_t nStart, const wchar_t* lpText, int32_t nLength);
const FDE_TXTEDTPARAMS* GetParams() const { return &m_Param; }
@@ -189,8 +199,8 @@ class CFDE_TxtEdtEngine {
void DeleteRange_DoRecord(int32_t nStart, int32_t nCount, bool bSel);
void ResetEngine();
void RebuildParagraphs();
- void RemoveAllParags();
- void RemoveAllPages();
+ void RemoveAllParags() { m_ParagPtrArray.clear(); }
+ void RemoveAllPages() { m_PagePtrArray.clear(); }
void UpdateLineCounts();
void UpdatePages();
void UpdateTxtBreak();
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 344bc65cf2..0eb2acb727 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -36,14 +36,6 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {}
-CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
- return m_pEditEngine.Get();
-}
-
-CFX_RectF CFDE_TxtEdtPage::GetRect(const FDE_TEXTEDITPIECE& hVisualObj) {
- return CFX_RectF();
-}
-
int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
CFX_RectF& rect,
bool bBBox) const {
@@ -129,14 +121,6 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) {
return nCaret;
}
-int32_t CFDE_TxtEdtPage::GetCharStart() const {
- return m_nPageStart;
-}
-
-int32_t CFDE_TxtEdtPage::GetCharCount() const {
- return m_nCharCount;
-}
-
int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
FXTEXT_CHARPOS*& pCharPos,
CFX_RectF* pBBox) const {
@@ -217,10 +201,6 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
return pIter->GetWordPos();
}
-bool CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) {
- return m_bLoaded;
-}
-
int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox) {
if (m_nRefCount > 0) {
m_nRefCount++;
@@ -403,14 +383,6 @@ void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) {
m_pIter.reset();
}
-const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() {
- return m_rtPageContents;
-}
-
-size_t CFDE_TxtEdtPage::GetTextPieceCount() const {
- return m_pTextSet ? m_Pieces.size() : 0;
-}
-
const FDE_TEXTEDITPIECE& CFDE_TxtEdtPage::GetTextPiece(size_t pos) const {
ASSERT(pos < m_Pieces.size());
return m_Pieces[pos];
diff --git a/xfa/fde/cfde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h
index e635ac726a..78814fb612 100644
--- a/xfa/fde/cfde_txtedtpage.h
+++ b/xfa/fde/cfde_txtedtpage.h
@@ -41,25 +41,25 @@ class CFDE_TxtEdtPage {
CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nLineIndex);
~CFDE_TxtEdtPage();
- CFX_RectF GetRect(const FDE_TEXTEDITPIECE& pPiece);
- CFDE_TxtEdtEngine* GetEngine() const;
+ CFX_RectF GetRect(const FDE_TEXTEDITPIECE& pPiece) { return CFX_RectF(); }
+ CFDE_TxtEdtEngine* GetEngine() const { return m_pEditEngine.Get(); }
int32_t GetCharRect(int32_t nIndex, CFX_RectF& rect, bool bBBox) const;
int32_t GetCharIndex(const CFX_PointF& fPoint, bool& bBefore);
void CalcRangeRectArray(int32_t nStart,
int32_t nCount,
std::vector<CFX_RectF>* RectFArr) const;
int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount);
- int32_t GetCharStart() const;
- int32_t GetCharCount() const;
+ int32_t GetCharStart() const { return m_nPageStart; }
+ int32_t GetCharCount() const { return m_nCharCount; }
int32_t GetDisplayPos(const CFX_RectF& rtClip,
FXTEXT_CHARPOS*& pCharPos,
CFX_RectF* pBBox) const;
- bool IsLoaded(const CFX_RectF* pClipBox);
+ bool IsLoaded(const CFX_RectF* pClipBox) { return m_bLoaded; }
int32_t LoadPage(const CFX_RectF* pClipBox);
void UnloadPage(const CFX_RectF* pClipBox);
- const CFX_RectF& GetContentsBox();
+ const CFX_RectF& GetContentsBox() { return m_rtPageContents; }
- size_t GetTextPieceCount() const;
+ size_t GetTextPieceCount() const { return m_pTextSet ? m_Pieces.size() : 0; }
const FDE_TEXTEDITPIECE& GetTextPiece(size_t pos) const;
wchar_t GetChar(const FDE_TEXTEDITPIECE* pIdentity, int32_t index) const;
diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp
index a68df2858c..79d6dd99c8 100644
--- a/xfa/fde/cfde_txtedttextset.cpp
+++ b/xfa/fde/cfde_txtedttextset.cpp
@@ -15,10 +15,6 @@ CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage)
CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {}
-CFX_RectF CFDE_TxtEdtTextSet::GetRect(const FDE_TEXTEDITPIECE& pPiece) const {
- return pPiece.rtPiece;
-}
-
int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece,
CFX_WideString& wsText) const {
wchar_t* pBuffer = wsText.GetBuffer(pPiece->nCount);
diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h
index 40c5623382..afaf22a719 100644
--- a/xfa/fde/cfde_txtedttextset.h
+++ b/xfa/fde/cfde_txtedttextset.h
@@ -18,7 +18,9 @@ class CFDE_TxtEdtTextSet {
explicit CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage);
~CFDE_TxtEdtTextSet();
- CFX_RectF GetRect(const FDE_TEXTEDITPIECE& hVisualObj) const;
+ CFX_RectF GetRect(const FDE_TEXTEDITPIECE& pPiece) const {
+ return pPiece.rtPiece;
+ }
int32_t GetString(FDE_TEXTEDITPIECE* pPiece, CFX_WideString& wsText) const;
CFX_RetainPtr<CFGAS_GEFont> GetFont() const;
float GetFontSize() const;
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 9e38187ef8..cf0df76583 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -734,8 +734,7 @@ void CFWL_Edit::UpdateEditLayout() {
}
bool CFWL_Edit::UpdateOffset() {
- CFX_RectF rtCaret;
- m_EdtEngine.GetCaretRect(rtCaret);
+ CFX_RectF rtCaret = m_EdtEngine.GetCaretRect();
float fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
float fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
rtCaret.Offset(fOffSetX, fOffSetY);
@@ -823,8 +822,7 @@ void CFWL_Edit::UpdateVAlignment() {
}
void CFWL_Edit::UpdateCaret() {
- CFX_RectF rtFDE;
- m_EdtEngine.GetCaretRect(rtFDE);
+ CFX_RectF rtFDE = m_EdtEngine.GetCaretRect();
rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX,
m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset);