summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn38
-rw-r--r--xfa.gyp42
-rw-r--r--xfa/fde/cfde_txtedtbuf.cpp (renamed from xfa/fee/fde_txtedtbuf.cpp)119
-rw-r--r--xfa/fde/cfde_txtedtbuf.h (renamed from xfa/fee/fde_txtedtbuf.h)33
-rw-r--r--xfa/fde/cfde_txtedtbufiter.cpp100
-rw-r--r--xfa/fde/cfde_txtedtbufiter.h35
-rw-r--r--xfa/fde/cfde_txtedtdorecord_deleterange.cpp55
-rw-r--r--xfa/fde/cfde_txtedtdorecord_deleterange.h36
-rw-r--r--xfa/fde/cfde_txtedtdorecord_insert.cpp47
-rw-r--r--xfa/fde/cfde_txtedtdorecord_insert.h33
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp (renamed from xfa/fee/fde_txtedtengine.cpp)220
-rw-r--r--xfa/fde/cfde_txtedtengine.h (renamed from xfa/fee/fde_txtedtengine.h)62
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp (renamed from xfa/fee/fde_txtedtpage.cpp)147
-rw-r--r--xfa/fde/cfde_txtedtpage.h (renamed from xfa/fee/fde_txtedtpage.h)90
-rw-r--r--xfa/fde/cfde_txtedtparag.cpp (renamed from xfa/fee/fde_txtedtparag.cpp)19
-rw-r--r--xfa/fde/cfde_txtedtparag.h (renamed from xfa/fee/fde_txtedtparag.h)6
-rw-r--r--xfa/fde/cfde_txtedttextset.cpp129
-rw-r--r--xfa/fde/cfde_txtedttextset.h41
-rw-r--r--xfa/fde/cfx_chariter.cpp51
-rw-r--r--xfa/fde/cfx_chariter.h31
-rw-r--r--xfa/fde/cfx_wordbreak.cpp (renamed from xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp)201
-rw-r--r--xfa/fde/cfx_wordbreak.h (renamed from xfa/fee/fx_wordbreak/fx_wordbreak.h)24
-rw-r--r--xfa/fde/ifde_txtedtdorecord.h20
-rw-r--r--xfa/fde/ifde_txtedtengine.h (renamed from xfa/fee/ifde_txtedtengine.h)18
-rw-r--r--xfa/fde/ifde_txtedtpage.h (renamed from xfa/fee/ifde_txtedtpage.h)6
-rw-r--r--xfa/fde/ifx_chariter.h24
-rw-r--r--xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp218
-rw-r--r--xfa/fee/fx_wordbreak/fx_wordbreak_impl.h37
-rw-r--r--xfa/fwl/basewidget/fwl_comboboximp.cpp2
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp4
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.h4
31 files changed, 1064 insertions, 828 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 30fd1e04f3..5e538e0096 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -896,6 +896,26 @@ if (pdf_enable_xfa) {
sources = [
"xfa/fde/cfde_path.cpp",
"xfa/fde/cfde_path.h",
+ "xfa/fde/cfde_txtedtbuf.cpp",
+ "xfa/fde/cfde_txtedtbuf.h",
+ "xfa/fde/cfde_txtedtbufiter.cpp",
+ "xfa/fde/cfde_txtedtbufiter.h",
+ "xfa/fde/cfde_txtedtdorecord_deleterange.cpp",
+ "xfa/fde/cfde_txtedtdorecord_deleterange.h",
+ "xfa/fde/cfde_txtedtdorecord_insert.cpp",
+ "xfa/fde/cfde_txtedtdorecord_insert.h",
+ "xfa/fde/cfde_txtedtengine.cpp",
+ "xfa/fde/cfde_txtedtengine.h",
+ "xfa/fde/cfde_txtedtpage.cpp",
+ "xfa/fde/cfde_txtedtpage.h",
+ "xfa/fde/cfde_txtedtparag.cpp",
+ "xfa/fde/cfde_txtedtparag.h",
+ "xfa/fde/cfde_txtedttextset.cpp",
+ "xfa/fde/cfde_txtedttextset.h",
+ "xfa/fde/cfx_chariter.cpp",
+ "xfa/fde/cfx_chariter.h",
+ "xfa/fde/cfx_wordbreak.cpp",
+ "xfa/fde/cfx_wordbreak.h",
"xfa/fde/css/fde_css.h",
"xfa/fde/css/fde_csscache.cpp",
"xfa/fde/css/fde_csscache.h",
@@ -916,25 +936,15 @@ if (pdf_enable_xfa) {
"xfa/fde/fde_object.h",
"xfa/fde/fde_render.cpp",
"xfa/fde/fde_render.h",
+ "xfa/fde/ifde_txtedtdorecord.h",
+ "xfa/fde/ifde_txtedtengine.h",
+ "xfa/fde/ifde_txtedtpage.h",
+ "xfa/fde/ifx_chariter.h",
"xfa/fde/tto/fde_textout.cpp",
"xfa/fde/tto/fde_textout.h",
"xfa/fde/xml/fde_xml.h",
"xfa/fde/xml/fde_xml_imp.cpp",
"xfa/fde/xml/fde_xml_imp.h",
- "xfa/fee/fde_txtedtbuf.cpp",
- "xfa/fee/fde_txtedtbuf.h",
- "xfa/fee/fde_txtedtengine.cpp",
- "xfa/fee/fde_txtedtengine.h",
- "xfa/fee/fde_txtedtpage.cpp",
- "xfa/fee/fde_txtedtpage.h",
- "xfa/fee/fde_txtedtparag.cpp",
- "xfa/fee/fde_txtedtparag.h",
- "xfa/fee/fx_wordbreak/fx_wordbreak.h",
- "xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp",
- "xfa/fee/fx_wordbreak/fx_wordbreak_impl.h",
- "xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp",
- "xfa/fee/ifde_txtedtengine.h",
- "xfa/fee/ifde_txtedtpage.h",
"xfa/fgas/crt/fgas_algorithm.cpp",
"xfa/fgas/crt/fgas_algorithm.h",
"xfa/fgas/crt/fgas_codepage.cpp",
diff --git a/xfa.gyp b/xfa.gyp
index f6293d5774..9387629fad 100644
--- a/xfa.gyp
+++ b/xfa.gyp
@@ -40,6 +40,28 @@
"xfa/fxfa/include/xfa_ffwidgethandler.h",
"xfa/fxfa/include/xfa_fontmgr.h",
"xfa/fxfa/include/xfa_rendercontext.h",
+ "xfa/fde/cfde_path.cpp",
+ "xfa/fde/cfde_path.h",
+ "xfa/fde/cfde_txtedtbufiter.cpp",
+ "xfa/fde/cfde_txtedtbufiter.h",
+ "xfa/fde/cfde_txtedtbuf.cpp",
+ "xfa/fde/cfde_txtedtbuf.h",
+ "xfa/fde/cfde_txtedtdorecord_deleterange.cpp",
+ "xfa/fde/cfde_txtedtdorecord_deleterange.h",
+ "xfa/fde/cfde_txtedtdorecord_insert.cpp",
+ "xfa/fde/cfde_txtedtdorecord_insert.h",
+ "xfa/fde/cfde_txtedtengine.cpp",
+ "xfa/fde/cfde_txtedtengine.h",
+ "xfa/fde/cfde_txtedtpage.cpp",
+ "xfa/fde/cfde_txtedtpage.h",
+ "xfa/fde/cfde_txtedtparag.cpp",
+ "xfa/fde/cfde_txtedtparag.h",
+ "xfa/fde/cfde_txtedttextset.cpp",
+ "xfa/fde/cfde_txtedttextset.h",
+ "xfa/fde/cfx_chariter.cpp",
+ "xfa/fde/cfx_chariter.h",
+ "xfa/fde/cfx_wordbreak.cpp",
+ "xfa/fde/cfx_wordbreak.h",
"xfa/fde/css/fde_css.h",
"xfa/fde/css/fde_csscache.cpp",
"xfa/fde/css/fde_csscache.h",
@@ -53,8 +75,6 @@
"xfa/fde/css/fde_cssstylesheet.h",
"xfa/fde/css/fde_csssyntax.cpp",
"xfa/fde/css/fde_csssyntax.h",
- "xfa/fde/cfde_path.cpp",
- "xfa/fde/cfde_path.h",
"xfa/fde/fde_gedevice.cpp",
"xfa/fde/fde_gedevice.h",
"xfa/fde/fde_iterator.cpp",
@@ -62,25 +82,15 @@
"xfa/fde/fde_object.h",
"xfa/fde/fde_render.cpp",
"xfa/fde/fde_render.h",
+ "xfa/fde/ifde_txtedtdorecord.h",
+ "xfa/fde/ifde_txtedtengine.h",
+ "xfa/fde/ifde_txtedtpage.h",
+ "xfa/fde/ifx_chariter.h",
"xfa/fde/tto/fde_textout.cpp",
"xfa/fde/tto/fde_textout.h",
"xfa/fde/xml/fde_xml.h",
"xfa/fde/xml/fde_xml_imp.cpp",
"xfa/fde/xml/fde_xml_imp.h",
- "xfa/fee/fde_txtedtbuf.cpp",
- "xfa/fee/fde_txtedtbuf.h",
- "xfa/fee/fde_txtedtengine.cpp",
- "xfa/fee/fde_txtedtengine.h",
- "xfa/fee/fde_txtedtpage.cpp",
- "xfa/fee/fde_txtedtpage.h",
- "xfa/fee/fde_txtedtparag.cpp",
- "xfa/fee/fde_txtedtparag.h",
- "xfa/fee/fx_wordbreak/fx_wordbreak.h",
- "xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp",
- "xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp",
- "xfa/fee/fx_wordbreak/fx_wordbreak_impl.h",
- "xfa/fee/ifde_txtedtengine.h",
- "xfa/fee/ifde_txtedtpage.h",
"xfa/fgas/crt/fgas_algorithm.cpp",
"xfa/fgas/crt/fgas_algorithm.h",
"xfa/fgas/crt/fgas_codepage.cpp",
diff --git a/xfa/fee/fde_txtedtbuf.cpp b/xfa/fde/cfde_txtedtbuf.cpp
index def92012e0..8bd5c1d37b 100644
--- a/xfa/fee/fde_txtedtbuf.cpp
+++ b/xfa/fde/cfde_txtedtbuf.cpp
@@ -4,137 +4,50 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fee/fde_txtedtbuf.h"
+#include "xfa/fde/cfde_txtedtbuf.h"
-#include <algorithm>
-
-#include "xfa/fee/ifde_txtedtengine.h"
+#include "xfa/fgas/crt/fgas_memory.h"
namespace {
const int kDefaultChunkSize = 1024;
+const int kDefaultChunkCount = 2;
} // namespace
-#define FDE_DEFCHUNKCOUNT 2
-#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9
-#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB
-#define FDE_TXTEDT_ZEROWIDTHSPACE 0x200B
-
-CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias)
- : m_pBuf(pBuf),
- m_nCurChunk(0),
- m_nCurIndex(0),
- m_nIndex(0),
- m_Alias(wcAlias) {
- ASSERT(m_pBuf);
-}
-
-CFDE_TxtEdtBufIter::~CFDE_TxtEdtBufIter() {}
-
-FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) {
- if (bPrev) {
- if (m_nIndex == 0) {
- return FALSE;
- }
- ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
- CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = nullptr;
- if (m_nCurIndex > 0) {
- m_nCurIndex--;
- } else {
- while (m_nCurChunk > 0) {
- --m_nCurChunk;
- lpChunk = m_pBuf->m_Chunks[m_nCurChunk];
- if (lpChunk->nUsed > 0) {
- m_nCurIndex = lpChunk->nUsed - 1;
- break;
- }
- }
- }
- ASSERT(m_nCurChunk >= 0);
- m_nIndex--;
- return TRUE;
- } else {
- if (m_nIndex >= (m_pBuf->m_nTotal - 1)) {
- return FALSE;
- }
- ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
- CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = m_pBuf->m_Chunks[m_nCurChunk];
- if (lpChunk->nUsed != (m_nCurIndex + 1)) {
- m_nCurIndex++;
- } else {
- int32_t nEnd = m_pBuf->m_Chunks.GetSize() - 1;
- while (m_nCurChunk < nEnd) {
- m_nCurChunk++;
- CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunkTemp =
- m_pBuf->m_Chunks[m_nCurChunk];
- if (lpChunkTemp->nUsed > 0) {
- m_nCurIndex = 0;
- break;
- }
- }
- }
- m_nIndex++;
- return TRUE;
- }
-}
-void CFDE_TxtEdtBufIter::SetAt(int32_t nIndex) {
- ASSERT(nIndex >= 0 && nIndex < m_pBuf->m_nTotal);
- CFDE_TxtEdtBuf::FDE_CHUNKPLACE cp;
- m_pBuf->Index2CP(nIndex, cp);
- m_nIndex = nIndex;
- m_nCurChunk = cp.nChunkIndex;
- m_nCurIndex = cp.nCharIndex;
-}
-int32_t CFDE_TxtEdtBufIter::GetAt() const {
- return m_nIndex;
-}
-FX_WCHAR CFDE_TxtEdtBufIter::GetChar() {
- ASSERT(m_nIndex >= 0 && m_nIndex < m_pBuf->m_nTotal);
- if (m_Alias == 0 || m_nIndex == (m_pBuf->m_nTotal - 1)) {
- return m_pBuf->m_Chunks[m_nCurChunk]->wChars[m_nCurIndex];
- }
- return m_Alias;
-}
-FX_BOOL CFDE_TxtEdtBufIter::IsEOF(FX_BOOL bTail) const {
- return bTail ? m_nIndex == (m_pBuf->GetTextLength() - 2) : m_nIndex == 0;
-}
-IFX_CharIter* CFDE_TxtEdtBufIter::Clone() {
- CFDE_TxtEdtBufIter* pIter = new CFDE_TxtEdtBufIter(m_pBuf);
- pIter->m_nCurChunk = m_nCurChunk;
- pIter->m_nCurIndex = m_nCurIndex;
- pIter->m_nIndex = m_nIndex;
- pIter->m_Alias = m_Alias;
- return pIter;
-}
-
CFDE_TxtEdtBuf::CFDE_TxtEdtBuf()
: m_nChunkSize(kDefaultChunkSize),
m_nTotal(0),
m_bChanged(FALSE),
m_pAllocator(NULL) {
ASSERT(m_nChunkSize);
- ResetChunkBuffer(FDE_DEFCHUNKCOUNT, m_nChunkSize);
+ ResetChunkBuffer(kDefaultChunkCount, m_nChunkSize);
}
+
void CFDE_TxtEdtBuf::Release() {
delete this;
}
+
CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() {
Clear(TRUE);
delete m_pAllocator;
m_Chunks.RemoveAll();
}
+
FX_BOOL CFDE_TxtEdtBuf::SetChunkSize(int32_t nChunkSize) {
ASSERT(nChunkSize);
- ResetChunkBuffer(FDE_DEFCHUNKCOUNT, nChunkSize);
+ ResetChunkBuffer(kDefaultChunkCount, nChunkSize);
return TRUE;
}
+
int32_t CFDE_TxtEdtBuf::GetChunkSize() const {
return m_nChunkSize;
}
+
int32_t CFDE_TxtEdtBuf::GetTextLength() const {
return m_nTotal;
}
+
void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
ASSERT(!wsText.IsEmpty());
Clear(FALSE);
@@ -166,9 +79,11 @@ void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
m_nTotal = nTextLength;
m_bChanged = TRUE;
}
+
void CFDE_TxtEdtBuf::GetText(CFX_WideString& wsText) const {
GetRange(wsText, 0, m_nTotal);
}
+
FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
ASSERT(nIndex >= 0 && nIndex < GetTextLength());
FDE_CHUNKHEADER* pChunkHeader = nullptr;
@@ -185,6 +100,7 @@ FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
ASSERT(pChunkHeader);
return pChunkHeader->wChars[pChunkHeader->nUsed - (nTotal - nIndex)];
}
+
void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
int32_t nBegin,
int32_t nLength) const {
@@ -214,6 +130,7 @@ void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
}
wsText.ReleaseBuffer();
}
+
void CFDE_TxtEdtBuf::Insert(int32_t nPos,
const FX_WCHAR* lpText,
int32_t nLength) {
@@ -265,6 +182,7 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos,
m_nTotal += nLength;
m_bChanged = TRUE;
}
+
void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) {
ASSERT(nLength > 0 && nIndex >= 0 && nIndex + nLength <= m_nTotal);
FDE_CHUNKPLACE cpEnd;
@@ -295,6 +213,7 @@ void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) {
}
m_bChanged = TRUE;
}
+
void CFDE_TxtEdtBuf::Clear(FX_BOOL bRelease) {
int32_t i = 0;
int32_t nCount = m_Chunks.GetSize();
@@ -311,6 +230,7 @@ void CFDE_TxtEdtBuf::Clear(FX_BOOL bRelease) {
m_nTotal = 0;
m_bChanged = TRUE;
}
+
FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) {
if (m_bChanged == FALSE) {
return TRUE;
@@ -357,6 +277,7 @@ FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) {
m_bChanged = FALSE;
return TRUE;
}
+
void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount,
int32_t nChunkSize) {
ASSERT(nChunkSize);
@@ -376,6 +297,7 @@ void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount,
m_Chunks.Add(lpChunkHeader);
m_nTotal = 0;
}
+
int32_t CFDE_TxtEdtBuf::CP2Index(const FDE_CHUNKPLACE& cp) const {
int32_t nTotal = cp.nCharIndex;
int32_t i = 0;
@@ -384,6 +306,7 @@ int32_t CFDE_TxtEdtBuf::CP2Index(const FDE_CHUNKPLACE& cp) const {
}
return nTotal;
}
+
void CFDE_TxtEdtBuf::Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const {
ASSERT(nIndex <= GetTextLength());
if (nIndex == m_nTotal) {
diff --git a/xfa/fee/fde_txtedtbuf.h b/xfa/fde/cfde_txtedtbuf.h
index bcfb66a0a1..0007fa4acd 100644
--- a/xfa/fee/fde_txtedtbuf.h
+++ b/xfa/fde/cfde_txtedtbuf.h
@@ -4,33 +4,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_FDE_TXTEDTBUF_H_
-#define XFA_FEE_FDE_TXTEDTBUF_H_
+#ifndef XFA_FDE_CFDE_TXTEDTBUF_H_
+#define XFA_FDE_CFDE_TXTEDTBUF_H_
-#include "xfa/fee/ifde_txtedtengine.h"
-#include "xfa/fgas/crt/fgas_memory.h"
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_system.h"
-class CFDE_TxtEdtBuf;
-
-class CFDE_TxtEdtBufIter : public IFX_CharIter {
- public:
- CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias = 0);
- ~CFDE_TxtEdtBufIter() override;
-
- FX_BOOL Next(FX_BOOL bPrev = FALSE) override;
- FX_WCHAR GetChar() override;
- void SetAt(int32_t nIndex) override;
- int32_t GetAt() const override;
- FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override;
- IFX_CharIter* Clone() override;
-
- private:
- CFDE_TxtEdtBuf* m_pBuf;
- int32_t m_nCurChunk;
- int32_t m_nCurIndex;
- int32_t m_nIndex;
- FX_WCHAR m_Alias;
-};
+class IFX_MemoryAllocator;
+class IFX_Pause;
class CFDE_TxtEdtBuf {
public:
@@ -81,4 +62,4 @@ class CFDE_TxtEdtBuf {
IFX_MemoryAllocator* m_pAllocator;
};
-#endif // XFA_FEE_FDE_TXTEDTBUF_H_
+#endif // XFA_FDE_CFDE_TXTEDTBUF_H_
diff --git a/xfa/fde/cfde_txtedtbufiter.cpp b/xfa/fde/cfde_txtedtbufiter.cpp
new file mode 100644
index 0000000000..c6d77a4523
--- /dev/null
+++ b/xfa/fde/cfde_txtedtbufiter.cpp
@@ -0,0 +1,100 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/cfde_txtedtbufiter.h"
+
+#include "xfa/fde/cfde_txtedtbuf.h"
+
+CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias)
+ : m_pBuf(pBuf),
+ m_nCurChunk(0),
+ m_nCurIndex(0),
+ m_nIndex(0),
+ m_Alias(wcAlias) {
+ ASSERT(m_pBuf);
+}
+
+CFDE_TxtEdtBufIter::~CFDE_TxtEdtBufIter() {}
+
+FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) {
+ if (bPrev) {
+ if (m_nIndex == 0) {
+ return FALSE;
+ }
+ ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
+ CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = nullptr;
+ if (m_nCurIndex > 0) {
+ m_nCurIndex--;
+ } else {
+ while (m_nCurChunk > 0) {
+ --m_nCurChunk;
+ lpChunk = m_pBuf->m_Chunks[m_nCurChunk];
+ if (lpChunk->nUsed > 0) {
+ m_nCurIndex = lpChunk->nUsed - 1;
+ break;
+ }
+ }
+ }
+ ASSERT(m_nCurChunk >= 0);
+ m_nIndex--;
+ return TRUE;
+ } else {
+ if (m_nIndex >= (m_pBuf->m_nTotal - 1)) {
+ return FALSE;
+ }
+ ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
+ CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = m_pBuf->m_Chunks[m_nCurChunk];
+ if (lpChunk->nUsed != (m_nCurIndex + 1)) {
+ m_nCurIndex++;
+ } else {
+ int32_t nEnd = m_pBuf->m_Chunks.GetSize() - 1;
+ while (m_nCurChunk < nEnd) {
+ m_nCurChunk++;
+ CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunkTemp =
+ m_pBuf->m_Chunks[m_nCurChunk];
+ if (lpChunkTemp->nUsed > 0) {
+ m_nCurIndex = 0;
+ break;
+ }
+ }
+ }
+ m_nIndex++;
+ return TRUE;
+ }
+}
+
+void CFDE_TxtEdtBufIter::SetAt(int32_t nIndex) {
+ ASSERT(nIndex >= 0 && nIndex < m_pBuf->m_nTotal);
+ CFDE_TxtEdtBuf::FDE_CHUNKPLACE cp;
+ m_pBuf->Index2CP(nIndex, cp);
+ m_nIndex = nIndex;
+ m_nCurChunk = cp.nChunkIndex;
+ m_nCurIndex = cp.nCharIndex;
+}
+
+int32_t CFDE_TxtEdtBufIter::GetAt() const {
+ return m_nIndex;
+}
+
+FX_WCHAR CFDE_TxtEdtBufIter::GetChar() {
+ ASSERT(m_nIndex >= 0 && m_nIndex < m_pBuf->m_nTotal);
+ if (m_Alias == 0 || m_nIndex == (m_pBuf->m_nTotal - 1))
+ return m_pBuf->m_Chunks[m_nCurChunk]->wChars[m_nCurIndex];
+ return m_Alias;
+}
+
+FX_BOOL CFDE_TxtEdtBufIter::IsEOF(FX_BOOL bTail) const {
+ return bTail ? m_nIndex == (m_pBuf->GetTextLength() - 2) : m_nIndex == 0;
+}
+
+IFX_CharIter* CFDE_TxtEdtBufIter::Clone() {
+ CFDE_TxtEdtBufIter* pIter = new CFDE_TxtEdtBufIter(m_pBuf);
+ pIter->m_nCurChunk = m_nCurChunk;
+ pIter->m_nCurIndex = m_nCurIndex;
+ pIter->m_nIndex = m_nIndex;
+ pIter->m_Alias = m_Alias;
+ return pIter;
+}
diff --git a/xfa/fde/cfde_txtedtbufiter.h b/xfa/fde/cfde_txtedtbufiter.h
new file mode 100644
index 0000000000..fc3a571ec2
--- /dev/null
+++ b/xfa/fde/cfde_txtedtbufiter.h
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFDE_TXTEDTBUFITER_H_
+#define XFA_FDE_CFDE_TXTEDTBUFITER_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fde/ifx_chariter.h"
+
+class CFDE_TxtEdtBuf;
+
+class CFDE_TxtEdtBufIter : public IFX_CharIter {
+ public:
+ CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias = 0);
+ ~CFDE_TxtEdtBufIter() override;
+
+ FX_BOOL Next(FX_BOOL bPrev = FALSE) override;
+ FX_WCHAR GetChar() override;
+ void SetAt(int32_t nIndex) override;
+ int32_t GetAt() const override;
+ FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override;
+ IFX_CharIter* Clone() override;
+
+ private:
+ CFDE_TxtEdtBuf* m_pBuf;
+ int32_t m_nCurChunk;
+ int32_t m_nCurIndex;
+ int32_t m_nIndex;
+ FX_WCHAR m_Alias;
+};
+
+#endif // XFA_FDE_CFDE_TXTEDTBUFITER_H_
diff --git a/xfa/fde/cfde_txtedtdorecord_deleterange.cpp b/xfa/fde/cfde_txtedtdorecord_deleterange.cpp
new file mode 100644
index 0000000000..b537ba4082
--- /dev/null
+++ b/xfa/fde/cfde_txtedtdorecord_deleterange.cpp
@@ -0,0 +1,55 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/cfde_txtedtdorecord_deleterange.h"
+
+#include "xfa/fde/cfde_txtedtengine.h"
+#include "xfa/fwl/basewidget/fwl_editimp.h"
+
+CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
+ CFDE_TxtEdtEngine* pEngine,
+ int32_t nIndex,
+ int32_t nCaret,
+ const CFX_WideString& wsRange,
+ FX_BOOL bSel)
+ : m_pEngine(pEngine),
+ m_bSel(bSel),
+ m_nIndex(nIndex),
+ m_nCaret(nCaret),
+ m_wsRange(wsRange) {
+ ASSERT(pEngine);
+}
+
+CFDE_TxtEdtDoRecord_DeleteRange::~CFDE_TxtEdtDoRecord_DeleteRange() {}
+
+FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() const {
+ if (m_pEngine->IsSelect())
+ m_pEngine->ClearSelection();
+
+ m_pEngine->Inner_Insert(m_nIndex, m_wsRange.c_str(), m_wsRange.GetLength());
+ if (m_bSel)
+ m_pEngine->AddSelRange(m_nIndex, m_wsRange.GetLength());
+
+ FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
+ m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
+ m_pEngine->m_ChangeInfo.wsDelete = m_wsRange;
+ Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
+ m_pEngine->SetCaretPos(m_nCaret, TRUE);
+ return TRUE;
+}
+
+FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Redo() const {
+ m_pEngine->Inner_DeleteRange(m_nIndex, m_wsRange.GetLength());
+ if (m_bSel)
+ m_pEngine->RemoveSelRange(m_nIndex, m_wsRange.GetLength());
+
+ FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
+ m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
+ m_pEngine->m_ChangeInfo.wsDelete = m_wsRange;
+ Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
+ m_pEngine->SetCaretPos(m_nIndex, TRUE);
+ return TRUE;
+}
diff --git a/xfa/fde/cfde_txtedtdorecord_deleterange.h b/xfa/fde/cfde_txtedtdorecord_deleterange.h
new file mode 100644
index 0000000000..c99c9e18d9
--- /dev/null
+++ b/xfa/fde/cfde_txtedtdorecord_deleterange.h
@@ -0,0 +1,36 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFDE_TXTEDTDORECORD_DELETERANGE_H_
+#define XFA_FDE_CFDE_TXTEDTDORECORD_DELETERANGE_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fde/ifde_txtedtdorecord.h"
+
+class CFDE_TxtEdtEngine;
+
+class CFDE_TxtEdtDoRecord_DeleteRange : public IFDE_TxtEdtDoRecord {
+ public:
+ CFDE_TxtEdtDoRecord_DeleteRange(CFDE_TxtEdtEngine* pEngine,
+ int32_t nIndex,
+ int32_t nCaret,
+ const CFX_WideString& wsRange,
+ FX_BOOL bSel = FALSE);
+ ~CFDE_TxtEdtDoRecord_DeleteRange() override;
+
+ FX_BOOL Undo() const override;
+ FX_BOOL Redo() const override;
+
+ private:
+ CFDE_TxtEdtEngine* m_pEngine;
+ FX_BOOL m_bSel;
+ int32_t m_nIndex;
+ int32_t m_nCaret;
+ CFX_WideString m_wsRange;
+};
+
+#endif // XFA_FDE_CFDE_TXTEDTDORECORD_DELETERANGE_H_
diff --git a/xfa/fde/cfde_txtedtdorecord_insert.cpp b/xfa/fde/cfde_txtedtdorecord_insert.cpp
new file mode 100644
index 0000000000..1505d14f95
--- /dev/null
+++ b/xfa/fde/cfde_txtedtdorecord_insert.cpp
@@ -0,0 +1,47 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/cfde_txtedtdorecord_insert.h"
+
+#include "xfa/fde/cfde_txtedtengine.h"
+#include "xfa/fwl/basewidget/fwl_editimp.h"
+
+CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
+ CFDE_TxtEdtEngine* pEngine,
+ int32_t nCaret,
+ const FX_WCHAR* lpText,
+ int32_t nLength)
+ : m_pEngine(pEngine), m_nCaret(nCaret) {
+ ASSERT(pEngine);
+ FX_WCHAR* lpBuffer = m_wsInsert.GetBuffer(nLength);
+ FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR));
+ m_wsInsert.ReleaseBuffer();
+}
+
+CFDE_TxtEdtDoRecord_Insert::~CFDE_TxtEdtDoRecord_Insert() {}
+
+FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() const {
+ if (m_pEngine->IsSelect())
+ m_pEngine->ClearSelection();
+
+ m_pEngine->Inner_DeleteRange(m_nCaret, m_wsInsert.GetLength());
+ FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
+ m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
+ m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert;
+ Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
+ m_pEngine->SetCaretPos(m_nCaret, TRUE);
+ return TRUE;
+}
+
+FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() const {
+ m_pEngine->Inner_Insert(m_nCaret, m_wsInsert.c_str(), m_wsInsert.GetLength());
+ FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
+ m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
+ m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert;
+ Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
+ m_pEngine->SetCaretPos(m_nCaret, FALSE);
+ return TRUE;
+}
diff --git a/xfa/fde/cfde_txtedtdorecord_insert.h b/xfa/fde/cfde_txtedtdorecord_insert.h
new file mode 100644
index 0000000000..38bbe57c1a
--- /dev/null
+++ b/xfa/fde/cfde_txtedtdorecord_insert.h
@@ -0,0 +1,33 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFDE_TXTEDTDORECORD_INSERT_H_
+#define XFA_FDE_CFDE_TXTEDTDORECORD_INSERT_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fde/ifde_txtedtdorecord.h"
+
+class CFDE_TxtEdtEngine;
+
+class CFDE_TxtEdtDoRecord_Insert : public IFDE_TxtEdtDoRecord {
+ public:
+ CFDE_TxtEdtDoRecord_Insert(CFDE_TxtEdtEngine* pEngine,
+ int32_t nCaret,
+ const FX_WCHAR* lpText,
+ int32_t nLength);
+ ~CFDE_TxtEdtDoRecord_Insert() override;
+
+ FX_BOOL Undo() const override;
+ FX_BOOL Redo() const override;
+
+ private:
+ CFDE_TxtEdtEngine* m_pEngine;
+ int32_t m_nCaret;
+ CFX_WideString m_wsInsert;
+};
+
+#endif // XFA_FDE_CFDE_TXTEDTDORECORD_INSERT_H_
diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index d1d33fe8c6..3162d397ee 100644
--- a/xfa/fee/fde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -4,22 +4,25 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fee/fde_txtedtengine.h"
+#include "xfa/fde/cfde_txtedtengine.h"
-#include <algorithm>
-#include <memory>
-
-#include "xfa/fde/tto/fde_textout.h"
-#include "xfa/fee/fde_txtedtparag.h"
-#include "xfa/fee/ifde_txtedtengine.h"
-#include "xfa/fee/ifde_txtedtpage.h"
+#include "xfa/fde/cfde_txtedtbuf.h"
+#include "xfa/fde/cfde_txtedtbufiter.h"
+#include "xfa/fde/ifx_chariter.h"
+#include "xfa/fgas/layout/fgas_textbreak.h"
#include "xfa/fwl/basewidget/fwl_editimp.h"
+#include "xfa/fde/cfde_txtedtdorecord_deleterange.h"
+#include "xfa/fde/cfde_txtedtdorecord_insert.h"
+#include "xfa/fde/cfde_txtedtparag.h"
+#include "xfa/fde/cfde_txtedtpage.h"
+#include "xfa/fde/tto/fde_textout.h"
+
+namespace {
-#define FDE_PAGEWIDTH_MAX 0xFFFF
-#define FDE_TXTPLATESIZE (1024 * 12)
-#define FDE_UNICODE_PARAGRAPH_SPERATOR (0x2029)
-#define FDE_TXTEDT_DORECORD_INS 0
-#define FDE_TXTEDT_DORECORD_DEL 1
+const uint32_t kPageWidthMax = 0xffff;
+const uint32_t kUnicodeParagraphSeparator = 0x2029;
+
+} // namespace
CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
: m_pTextBreak(nullptr),
@@ -37,11 +40,12 @@ CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
m_wcAliasChar(L'*'),
m_nFirstLineEnd(FDE_TXTEDIT_LINEEND_Auto),
m_bAutoLineEnd(TRUE),
- m_wLineEnd(FDE_UNICODE_PARAGRAPH_SPERATOR) {
+ m_wLineEnd(kUnicodeParagraphSeparator) {
FXSYS_memset(&m_rtCaret, 0, sizeof(CFX_RectF));
m_pTxtBuf = new CFDE_TxtEdtBuf();
m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto);
}
+
CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
if (m_pTxtBuf) {
m_pTxtBuf->Release();
@@ -56,9 +60,11 @@ CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
m_Param.pEventSink = NULL;
ClearSelection();
}
+
void CFDE_TxtEdtEngine::Release() {
delete this;
}
+
void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
if (!m_pTextBreak)
m_pTextBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
@@ -68,24 +74,29 @@ void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto);
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;
}
+
IFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) {
if (m_PagePtrArray.GetSize() <= nIndex) {
return NULL;
}
return (IFDE_TxtEdtPage*)m_PagePtrArray[nIndex];
}
+
FX_BOOL CFDE_TxtEdtEngine::SetBufChunkSize(int32_t nChunkSize) {
return m_pTxtBuf->SetChunkSize(nChunkSize);
}
+
void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) {
ResetEngine();
int32_t nIndex = 0;
@@ -115,6 +126,7 @@ void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) {
m_pTxtBuf->Insert(nIndex, &m_wLineEnd, 1);
RebuildParagraphs();
}
+
void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
ResetEngine();
int32_t nLength = wsText.GetLength();
@@ -133,9 +145,11 @@ void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1);
RebuildParagraphs();
}
+
int32_t CFDE_TxtEdtEngine::GetTextLength() const {
return GetTextBufLength();
}
+
void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText,
int32_t nStart,
int32_t nCount) {
@@ -150,16 +164,19 @@ void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText,
void CFDE_TxtEdtEngine::ClearText() {
DeleteRange(0, -1);
}
+
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, FX_BOOL bBefore) {
if (IsLocked()) {
return 0;
@@ -183,6 +200,7 @@ int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
m_nAnchorPos = -1;
return m_nCaret;
}
+
int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
FX_BOOL bShift,
FX_BOOL bCtrl) {
@@ -301,15 +319,19 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
}
return m_nCaret;
}
+
void CFDE_TxtEdtEngine::Lock() {
m_bLock = TRUE;
}
+
void CFDE_TxtEdtEngine::Unlock() {
m_bLock = FALSE;
}
+
FX_BOOL CFDE_TxtEdtEngine::IsLocked() const {
return m_bLock;
}
+
int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
const FX_WCHAR* lpText,
int32_t nLength) {
@@ -404,6 +426,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal;
}
+
int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) {
if (IsLocked()) {
return FDE_TXTEDT_MODIFY_RET_F_Locked;
@@ -456,6 +479,7 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) {
m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
+
int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) {
if (IsLocked()) {
return FDE_TXTEDT_MODIFY_RET_F_Locked;
@@ -478,6 +502,7 @@ int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) {
SetCaretPos(nStart, TRUE);
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
+
int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
int32_t nLength,
const CFX_WideString& wsReplace) {
@@ -521,9 +546,11 @@ int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
+
void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) {
m_nLimit = nLimit;
}
+
void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) {
m_wcAliasChar = wcAlias;
}
@@ -614,6 +641,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
int32_t CFDE_TxtEdtEngine::CountSelRanges() {
return m_SelRangePtrArr.GetSize();
}
+
int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) {
nStart = m_SelRangePtrArr[nIndex]->nStart;
return m_SelRangePtrArr[nIndex]->nCount;
@@ -651,6 +679,7 @@ int32_t CFDE_TxtEdtEngine::StartLayout() {
m_nLineCount = 0;
return 0;
}
+
int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) {
int32_t nCount = m_ParagPtrArray.GetSize();
CFDE_TxtEdtParag* pParag = NULL;
@@ -668,6 +697,7 @@ int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) {
m_nLineCount += nLineCount;
return 100;
}
+
void CFDE_TxtEdtEngine::EndLayout() {
UpdatePages();
int32_t nLength = GetTextLength();
@@ -681,36 +711,46 @@ void CFDE_TxtEdtEngine::EndLayout() {
m_rtCaret.Set(0, 0, 1, m_Param.fFontSize);
Unlock();
}
+
FX_BOOL CFDE_TxtEdtEngine::Optimize(IFX_Pause* pPause) {
return m_pTxtBuf->Optimize(pPause);
}
+
CFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const {
return m_pTxtBuf;
}
+
int32_t CFDE_TxtEdtEngine::GetTextBufLength() const {
return m_pTxtBuf->GetTextLength() - 1;
}
+
CFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const {
return m_pTextBreak;
}
+
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 m_ParagPtrArray.GetSize();
}
+
CFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const {
return m_ParagPtrArray[nParagIndex];
}
+
IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() {
if (!m_pTxtBuf) {
return NULL;
}
return new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf);
}
+
int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
int32_t nStartLineofParag,
int32_t nLineIndex,
@@ -729,12 +769,14 @@ int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
nStartLine = nLineTotal - pParag->GetLineCount();
return i;
}
+
void CFDE_TxtEdtEngine::GetPreDeleteText(CFX_WideString& wsText,
int32_t nIndex,
int32_t nLength) {
GetText(wsText, 0, GetTextBufLength());
wsText.Delete(nIndex, nLength);
}
+
void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText,
int32_t nIndex,
const FX_WCHAR* lpText,
@@ -759,6 +801,7 @@ void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText,
wsTemp.ReleaseBuffer(nOldLength + nLength);
wsText = wsTemp;
}
+
void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText,
int32_t nIndex,
int32_t nOriginLength,
@@ -778,6 +821,7 @@ void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText,
wsText.Insert(nIndex++, lpText[i]);
}
}
+
void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
const FX_WCHAR* lpText,
int32_t nLength) {
@@ -896,6 +940,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
}
m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
}
+
void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
int32_t nCount,
FX_BOOL bSel) {
@@ -916,6 +961,7 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
GetText(m_ChangeInfo.wsDelete, nStart, nCount);
Inner_DeleteRange(nStart, nCount);
}
+
void CFDE_TxtEdtEngine::ResetEngine() {
RemoveAllPages();
RemoveAllParags();
@@ -924,6 +970,7 @@ void CFDE_TxtEdtEngine::ResetEngine() {
m_pTxtBuf->Clear(FALSE);
m_nCaret = 0;
}
+
void CFDE_TxtEdtEngine::RebuildParagraphs() {
RemoveAllParags();
FX_WCHAR wChar = L' ';
@@ -964,6 +1011,7 @@ void CFDE_TxtEdtEngine::RemoveAllPages() {
}
m_PagePtrArray.RemoveAll();
}
+
void CFDE_TxtEdtEngine::UpdateParags() {
int32_t nCount = m_ParagPtrArray.GetSize();
if (nCount == 0) {
@@ -981,6 +1029,7 @@ void CFDE_TxtEdtEngine::UpdateParags() {
}
m_nLineCount = nLineCount;
}
+
void CFDE_TxtEdtEngine::UpdatePages() {
if (m_nLineCount == 0)
return;
@@ -1012,6 +1061,7 @@ void CFDE_TxtEdtEngine::UpdatePages() {
return;
}
}
+
void CFDE_TxtEdtEngine::UpdateTxtBreak() {
uint32_t dwStyle = m_pTextBreak->GetLayoutStyles();
if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines) {
@@ -1076,13 +1126,13 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() {
if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) {
m_pTextBreak->SetLineWidth(m_Param.fPlateHeight);
} else {
- m_pTextBreak->SetLineWidth(FDE_PAGEWIDTH_MAX);
+ m_pTextBreak->SetLineWidth(kPageWidthMax);
}
} else {
if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) {
m_pTextBreak->SetLineWidth(m_Param.fPlateWidth);
} else {
- m_pTextBreak->SetLineWidth(FDE_PAGEWIDTH_MAX);
+ m_pTextBreak->SetLineWidth(kPageWidthMax);
}
}
m_nPageLineCount = m_Param.nLineCount;
@@ -1106,6 +1156,7 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() {
m_pTextBreak->SetHorizontalScale(m_Param.nHorzScale);
m_pTextBreak->SetCharSpace(m_Param.fCharSpace);
}
+
FX_BOOL CFDE_TxtEdtEngine::ReplaceParagEnd(FX_WCHAR*& lpText,
int32_t& nLength,
FX_BOOL bPreIsCR) {
@@ -1149,6 +1200,7 @@ FX_BOOL CFDE_TxtEdtEngine::ReplaceParagEnd(FX_WCHAR*& lpText,
}
return bPreIsCR;
}
+
void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r';
if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) {
@@ -1188,12 +1240,12 @@ void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
int32_t nLength = wsText.GetLength();
FX_WCHAR* lpBuf = const_cast<FX_WCHAR*>(wsText.c_str());
for (int32_t i = 0; i < nLength; i++, lpBuf++) {
- if (*lpBuf == m_wLineEnd) {
+ if (*lpBuf == m_wLineEnd)
*lpBuf = wc;
- }
}
}
}
+
int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
ASSERT(nIndex >= 0);
ASSERT(nIndex <= m_pTxtBuf->GetTextLength());
@@ -1225,9 +1277,8 @@ int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
int32_t nLineCharCount = -1;
for (i = 0; i < pParag->GetLineCount(); i++) {
pParag->GetLineRange(i, nLineStart, nLineCharCount);
- if (nLineStart <= nIndex && nIndex < (nLineStart + nLineCharCount)) {
+ if (nLineStart <= nIndex && nIndex < (nLineStart + nLineCharCount))
break;
- }
}
ASSERT(i < pParag->GetLineCount());
nLineCount += (i + 1);
@@ -1235,6 +1286,7 @@ int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
pParag->UnloadParag();
return m_nCaretPage;
}
+
void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex,
FDE_TXTEDTPARAGPOS& ParagPos) const {
ASSERT(nIndex >= 0 && nIndex < m_pTxtBuf->GetTextLength());
@@ -1245,27 +1297,27 @@ void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex,
while (nEnd > nBgn) {
nMid = (nBgn + nEnd) / 2;
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nMid];
- if (nIndex < pParag->GetStartIndex()) {
+ if (nIndex < pParag->GetStartIndex())
nEnd = nMid - 1;
- } else if (nIndex >= (pParag->GetStartIndex() + pParag->GetTextLength())) {
+ else if (nIndex >= (pParag->GetStartIndex() + pParag->GetTextLength()))
nBgn = nMid + 1;
- } else {
+ else
break;
- }
}
- if (nBgn == nEnd) {
+ if (nBgn == nEnd)
nMid = nBgn;
- }
+
ASSERT(nIndex >= m_ParagPtrArray[nMid]->GetStartIndex() &&
(nIndex < m_ParagPtrArray[nMid]->GetStartIndex() +
m_ParagPtrArray[nMid]->GetTextLength()));
ParagPos.nParagIndex = nMid;
ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->GetStartIndex();
}
+
int32_t CFDE_TxtEdtEngine::MoveForward(FX_BOOL& bBefore) {
- if (m_nCaret == m_pTxtBuf->GetTextLength() - 1) {
+ if (m_nCaret == m_pTxtBuf->GetTextLength() - 1)
return -1;
- }
+
int32_t nCaret = m_nCaret;
if ((nCaret + 1 < m_pTxtBuf->GetTextLength()) &&
(m_pTxtBuf->GetCharByIndex(nCaret) == L'\r') &&
@@ -1276,10 +1328,11 @@ int32_t CFDE_TxtEdtEngine::MoveForward(FX_BOOL& bBefore) {
bBefore = TRUE;
return nCaret;
}
+
int32_t CFDE_TxtEdtEngine::MoveBackward(FX_BOOL& bBefore) {
- if (m_nCaret == 0) {
+ if (m_nCaret == 0)
return FALSE;
- }
+
int32_t nCaret = m_nCaret;
if (nCaret > 2 && m_pTxtBuf->GetCharByIndex(nCaret - 1) == L'\n' &&
m_pTxtBuf->GetCharByIndex(nCaret - 2) == L'\r') {
@@ -1289,6 +1342,7 @@ int32_t CFDE_TxtEdtEngine::MoveBackward(FX_BOOL& bBefore) {
bBefore = TRUE;
return nCaret;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) {
IFDE_TxtEdtPage* pPage = GetPage(m_nCaretPage);
const CFX_RectF& rtContent = pPage->GetContentsBox();
@@ -1331,6 +1385,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) {
}
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) {
IFDE_TxtEdtPage* pPage = GetPage(m_nCaretPage);
const CFX_RectF& rtContent = pPage->GetContentsBox();
@@ -1373,6 +1428,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) {
}
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveLineStart() {
int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1;
FDE_TXTEDTPARAGPOS ParagPos;
@@ -1393,6 +1449,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineStart() {
pParag->UnloadParag();
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() {
int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1;
FDE_TXTEDTPARAGPOS ParagPos;
@@ -1429,6 +1486,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() {
pParag->UnloadParag();
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveParagStart() {
int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1;
FDE_TXTEDTPARAGPOS ParagPos;
@@ -1437,6 +1495,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveParagStart() {
UpdateCaretRect(pParag->GetStartIndex(), TRUE);
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() {
int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1;
FDE_TXTEDTPARAGPOS ParagPos;
@@ -1454,10 +1513,12 @@ FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() {
UpdateCaretRect(nIndex, TRUE);
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveHome() {
UpdateCaretRect(0, TRUE);
return TRUE;
}
+
FX_BOOL CFDE_TxtEdtEngine::MoveEnd() {
UpdateCaretRect(GetTextBufLength(), TRUE);
return TRUE;
@@ -1471,9 +1532,9 @@ FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
CFX_RectF rcText;
FXSYS_memset(&rcText, 0, sizeof(rcText));
uint32_t dwStyle = 0;
- if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)) {
+ if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines))
dwStyle |= FDE_TTOSTYLE_SingleLine;
- }
+
if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) {
dwStyle |= FDE_TTOSTYLE_LineWrap;
rcText.width = m_Param.fPlateWidth;
@@ -1494,6 +1555,7 @@ FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
}
return TRUE;
}
+
void CFDE_TxtEdtEngine::UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore) {
MovePage2Char(nIndex);
GetCaretRect(m_rtCaret, m_nCaretPage, nIndex, bBefore);
@@ -1508,6 +1570,7 @@ void CFDE_TxtEdtEngine::UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore) {
: m_rtCaret.left;
m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0);
}
+
void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret,
int32_t nPageIndex,
int32_t nCaret,
@@ -1526,22 +1589,23 @@ void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret,
(FX_IsOdd(nBIDILevel) && bBefore)) {
rtCaret.Offset(0, rtCaret.height - 1.0f);
}
- if (rtCaret.height == 0 && rtCaret.top > 1.0f) {
+ if (rtCaret.height == 0 && rtCaret.top > 1.0f)
rtCaret.top -= 1.0f;
- }
+
rtCaret.height = 1.0f;
} else {
if ((!FX_IsOdd(nBIDILevel) && !bBefore) ||
(FX_IsOdd(nBIDILevel) && bBefore)) {
rtCaret.Offset(rtCaret.width - 1.0f, 0);
}
- if (rtCaret.width == 0 && rtCaret.left > 1.0f) {
+ if (rtCaret.width == 0 && rtCaret.left > 1.0f)
rtCaret.left -= 1.0f;
- }
+
rtCaret.width = 1.0f;
}
m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
}
+
void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) {
IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
@@ -1554,9 +1618,11 @@ void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) {
m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage);
m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
}
+
FX_BOOL CFDE_TxtEdtEngine::IsSelect() {
return m_SelRangePtrArr.GetSize() > 0;
}
+
void CFDE_TxtEdtEngine::DeleteSelect() {
int32_t nCountRange = CountSelRanges();
if (nCountRange > 0) {
@@ -1575,85 +1641,3 @@ void CFDE_TxtEdtEngine::DeleteSelect() {
return;
}
}
-
-CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
- CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- const FX_WCHAR* lpText,
- int32_t nLength)
- : m_pEngine(pEngine), m_nCaret(nCaret) {
- ASSERT(pEngine);
- FX_WCHAR* lpBuffer = m_wsInsert.GetBuffer(nLength);
- FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR));
- m_wsInsert.ReleaseBuffer();
-}
-
-CFDE_TxtEdtDoRecord_Insert::~CFDE_TxtEdtDoRecord_Insert() {}
-
-FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() const {
- if (m_pEngine->IsSelect()) {
- m_pEngine->ClearSelection();
- }
- m_pEngine->Inner_DeleteRange(m_nCaret, m_wsInsert.GetLength());
- FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
- m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
- m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert;
- Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
- m_pEngine->SetCaretPos(m_nCaret, TRUE);
- return TRUE;
-}
-
-FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() const {
- m_pEngine->Inner_Insert(m_nCaret, m_wsInsert.c_str(), m_wsInsert.GetLength());
- FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
- m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
- m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert;
- Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
- m_pEngine->SetCaretPos(m_nCaret, FALSE);
- return TRUE;
-}
-
-CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
- CFDE_TxtEdtEngine* pEngine,
- int32_t nIndex,
- int32_t nCaret,
- const CFX_WideString& wsRange,
- FX_BOOL bSel)
- : m_pEngine(pEngine),
- m_bSel(bSel),
- m_nIndex(nIndex),
- m_nCaret(nCaret),
- m_wsRange(wsRange) {
- ASSERT(pEngine);
-}
-
-CFDE_TxtEdtDoRecord_DeleteRange::~CFDE_TxtEdtDoRecord_DeleteRange() {}
-
-FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() const {
- if (m_pEngine->IsSelect()) {
- m_pEngine->ClearSelection();
- }
- m_pEngine->Inner_Insert(m_nIndex, m_wsRange.c_str(), m_wsRange.GetLength());
- if (m_bSel) {
- m_pEngine->AddSelRange(m_nIndex, m_wsRange.GetLength());
- }
- FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
- m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
- m_pEngine->m_ChangeInfo.wsDelete = m_wsRange;
- Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
- m_pEngine->SetCaretPos(m_nCaret, TRUE);
- return TRUE;
-}
-
-FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Redo() const {
- m_pEngine->Inner_DeleteRange(m_nIndex, m_wsRange.GetLength());
- if (m_bSel) {
- m_pEngine->RemoveSelRange(m_nIndex, m_wsRange.GetLength());
- }
- FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param;
- m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
- m_pEngine->m_ChangeInfo.wsDelete = m_wsRange;
- Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo);
- m_pEngine->SetCaretPos(m_nIndex, TRUE);
- return TRUE;
-}
diff --git a/xfa/fee/fde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index 585caa1eb6..afe55ce505 100644
--- a/xfa/fee/fde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -4,27 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_FDE_TXTEDTENGINE_H_
-#define XFA_FEE_FDE_TXTEDTENGINE_H_
+#ifndef XFA_FDE_CFDE_TXTEDTENGINE_H_
+#define XFA_FDE_CFDE_TXTEDTENGINE_H_
-#include "core/fxcrt/include/fx_string.h"
-#include "xfa/fee/fde_txtedtbuf.h"
-#include "xfa/fee/ifde_txtedtengine.h"
-#include "xfa/fgas/layout/fgas_textbreak.h"
+#include "xfa/fde/ifde_txtedtengine.h"
+class CFDE_TxtEdtBuf;
+class CFDE_TxtEdtParag;
class CFX_TxtBreak;
+class IFDE_TxtEdtDoRecord;
class IFX_CharIter;
-class CFDE_TxtEdtParag;
-class CFDE_TxtEdtDoRecord_Insert;
-class CFDE_TxtEdtDoRecord_DeleteRange;
-
-class IFDE_TxtEdtDoRecord {
- public:
- virtual ~IFDE_TxtEdtDoRecord() {}
-
- virtual FX_BOOL Redo() const = 0;
- virtual FX_BOOL Undo() const = 0;
-};
class CFDE_TxtEdtEngine {
public:
@@ -191,41 +180,4 @@ class CFDE_TxtEdtEngine {
FDE_TXTEDT_TEXTCHANGE_INFO m_ChangeInfo;
};
-class CFDE_TxtEdtDoRecord_Insert : public IFDE_TxtEdtDoRecord {
- public:
- CFDE_TxtEdtDoRecord_Insert(CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- const FX_WCHAR* lpText,
- int32_t nLength);
- ~CFDE_TxtEdtDoRecord_Insert() override;
-
- FX_BOOL Undo() const override;
- FX_BOOL Redo() const override;
-
- private:
- CFDE_TxtEdtEngine* m_pEngine;
- int32_t m_nCaret;
- CFX_WideString m_wsInsert;
-};
-
-class CFDE_TxtEdtDoRecord_DeleteRange : public IFDE_TxtEdtDoRecord {
- public:
- CFDE_TxtEdtDoRecord_DeleteRange(CFDE_TxtEdtEngine* pEngine,
- int32_t nIndex,
- int32_t nCaret,
- const CFX_WideString& wsRange,
- FX_BOOL bSel = FALSE);
- ~CFDE_TxtEdtDoRecord_DeleteRange() override;
-
- FX_BOOL Undo() const override;
- FX_BOOL Redo() const override;
-
- private:
- CFDE_TxtEdtEngine* m_pEngine;
- FX_BOOL m_bSel;
- int32_t m_nIndex;
- int32_t m_nCaret;
- CFX_WideString m_wsRange;
-};
-
-#endif // XFA_FEE_FDE_TXTEDTENGINE_H_
+#endif // XFA_FDE_CFDE_TXTEDTENGINE_H_
diff --git a/xfa/fee/fde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 87d128ad56..b018d30bad 100644
--- a/xfa/fee/fde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -4,123 +4,30 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fee/fde_txtedtpage.h"
+#include "xfa/fde/cfde_txtedtpage.h"
#include <algorithm>
-#include "xfa/fee/fde_txtedtbuf.h"
-#include "xfa/fee/fde_txtedtengine.h"
-#include "xfa/fee/fde_txtedtparag.h"
-#include "xfa/fee/fx_wordbreak/fx_wordbreak.h"
-#include "xfa/fee/ifde_txtedtengine.h"
-#include "xfa/fee/ifde_txtedtpage.h"
+#include "xfa/fde/cfde_txtedtbuf.h"
+#include "xfa/fde/cfde_txtedtbufiter.h"
+#include "xfa/fde/cfde_txtedtengine.h"
+#include "xfa/fde/cfde_txtedtparag.h"
+#include "xfa/fde/ifde_txtedtengine.h"
+#include "xfa/fde/ifde_txtedtpage.h"
+#include "xfa/fde/cfde_txtedttextset.h"
+#include "xfa/fde/cfx_wordbreak.h"
-#define FDE_TXTEDT_TOLERANCE 0.1f
+namespace {
+
+const double kTolerance = 0.1f;
+
+} // namespace
IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine,
int32_t nIndex) {
return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex);
}
-CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage)
- : m_pPage(pPage) {}
-CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {}
-FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() {
- return FDE_VISUALOBJ_Text;
-}
-FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj,
- CFX_RectF& bbox) {
- return FALSE;
-}
-FX_BOOL CFDE_TxtEdtTextSet::GetMatrix(FDE_HVISUALOBJ hVisualObj,
- CFX_Matrix& matrix) {
- return FALSE;
-}
-FX_BOOL CFDE_TxtEdtTextSet::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
- rt = ((FDE_TEXTEDITPIECE*)(hVisualObj))->rtPiece;
- return TRUE;
-}
-FX_BOOL CFDE_TxtEdtTextSet::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
- return FALSE;
-}
-int32_t CFDE_TxtEdtTextSet::GetString(FDE_HVISUALOBJ hText,
- CFX_WideString& wsText) {
- FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText;
- FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount);
- for (int32_t i = 0; i < pPiece->nCount; i++) {
- pBuffer[i] = m_pPage->GetChar((void*)hText, i);
- }
- wsText.ReleaseBuffer(pPiece->nCount);
- return pPiece->nCount;
-}
-IFX_Font* CFDE_TxtEdtTextSet::GetFont(FDE_HVISUALOBJ hText) {
- return m_pPage->GetEngine()->GetEditParams()->pFont;
-}
-FX_FLOAT CFDE_TxtEdtTextSet::GetFontSize(FDE_HVISUALOBJ hText) {
- return m_pPage->GetEngine()->GetEditParams()->fFontSize;
-}
-FX_ARGB CFDE_TxtEdtTextSet::GetFontColor(FDE_HVISUALOBJ hText) {
- return m_pPage->GetEngine()->GetEditParams()->dwFontColor;
-}
-int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode,
- CFX_WideString* pWSForms) {
- if (hText == NULL) {
- return 0;
- }
- FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText;
- int32_t nLength = pPiece->nCount;
- if (nLength < 1) {
- return 0;
- }
- CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine());
- const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams();
- CFX_TxtBreak* pBreak = pEngine->GetTextBreak();
- uint32_t dwLayoutStyle = pBreak->GetLayoutStyles();
- FX_TXTRUN tr;
- tr.pAccess = m_pPage;
- tr.pIdentity = (void*)hText;
- tr.iLength = nLength;
- tr.pFont = pTextParams->pFont;
- tr.fFontSize = pTextParams->fFontSize;
- tr.dwStyles = dwLayoutStyle;
- tr.iCharRotation = pTextParams->nCharRotation;
- tr.dwCharStyles = pPiece->dwCharStyles;
- tr.pRect = &(pPiece->rtPiece);
- tr.wLineBreakChar = pTextParams->wLineBreakChar;
- return pBreak->GetDisplayPos(&tr, pCharPos, bCharCode, pWSForms);
-}
-int32_t CFDE_TxtEdtTextSet::GetCharRects(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray) {
- return GetCharRects_Impl(hText, rtArray);
-}
-int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray,
- FX_BOOL bBBox) {
- if (hText == NULL) {
- return 0;
- }
- FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText;
- CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine());
- int32_t nLength = pPiece->nCount;
- if (nLength < 1) {
- return 0;
- }
- const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams();
- uint32_t dwLayoutStyle = pEngine->GetTextBreak()->GetLayoutStyles();
- FX_TXTRUN tr;
- tr.pAccess = m_pPage;
- tr.pIdentity = (void*)hText;
- tr.iLength = nLength;
- tr.pFont = pTextParams->pFont;
- tr.fFontSize = pTextParams->fFontSize;
- tr.dwStyles = dwLayoutStyle;
- tr.iCharRotation = pTextParams->nCharRotation;
- tr.dwCharStyles = pPiece->dwCharStyles;
- tr.pRect = &(pPiece->rtPiece);
- tr.wLineBreakChar = pTextParams->wLineBreakChar;
- return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox);
-}
+
CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
: m_pIter(nullptr),
m_pTextSet(nullptr),
@@ -148,25 +55,32 @@ CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
void CFDE_TxtEdtPage::Release() {
delete this;
}
+
CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
return m_pEditEngine;
}
+
FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() {
return FDE_VISUALOBJ_Text;
}
+
FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) {
return FALSE;
}
+
FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj,
CFX_Matrix& matrix) {
return FALSE;
}
+
FX_BOOL CFDE_TxtEdtPage::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
return FALSE;
}
+
FX_BOOL CFDE_TxtEdtPage::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
return FALSE;
}
+
int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
CFX_RectF& rect,
FX_BOOL bBBox) const {
@@ -193,12 +107,13 @@ int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
ASSERT(0);
return 0;
}
+
int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint,
FX_BOOL& bBefore) {
FX_BOOL bVertical = m_pEditEngine->GetEditParams()->dwLayoutStyles &
FDE_TEXTEDITLAYOUT_DocVertical;
CFX_PointF ptF = fPoint;
- NormalizePt2Rect(ptF, m_rtPageContents, FDE_TXTEDT_TOLERANCE);
+ NormalizePt2Rect(ptF, m_rtPageContents, kTolerance);
int32_t nCount = m_PieceMassArr.GetSize();
CFX_RectF rtLine;
int32_t nBgn = 0;
@@ -226,7 +141,7 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint,
}
}
}
- NormalizePt2Rect(ptF, rtLine, FDE_TXTEDT_TOLERANCE);
+ NormalizePt2Rect(ptF, rtLine, kTolerance);
int32_t nCaret = 0;
FDE_TEXTEDITPIECE* pPiece = NULL;
for (i = nBgn; i <= nEnd; i++) {
@@ -269,12 +184,15 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint,
bBefore = TRUE;
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 {
@@ -302,6 +220,7 @@ int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
}
return nCharPosCount;
}
+
void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart,
int32_t nCount,
CFX_RectFArray& RectFArr) const {
@@ -361,9 +280,11 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
nCount = pIter->GetWordLength();
return pIter->GetWordPos();
}
+
FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) {
return m_bLoaded;
}
+
int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
IFX_Pause* pPause) {
if (m_nRefCount > 0) {
@@ -567,12 +488,14 @@ void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) {
const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() {
return m_rtPageContents;
}
+
FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) {
if (m_PieceMassArr.GetSize() < 1) {
return NULL;
}
return (FX_POSITION)1;
}
+
FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas,
FX_POSITION& pos,
IFDE_VisualSet*& pVisualSet) {
@@ -589,10 +512,12 @@ FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas,
}
return (FDE_HVISUALOBJ)(m_PieceMassArr.GetPtrAt(nPos - 1));
}
+
FDE_HVISUALOBJ CFDE_TxtEdtPage::GetParentCanvas(FDE_HVISUALOBJ hCanvas,
IFDE_VisualSet*& pVisualSet) {
return NULL;
}
+
FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const {
int32_t nIndex =
m_nPageStart + ((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index;
@@ -603,11 +528,13 @@ FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const {
m_pIter->Next();
return wChar;
}
+
int32_t CFDE_TxtEdtPage::GetWidth(void* pIdentity, int32_t index) const {
int32_t nWidth =
m_pCharWidth[((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index];
return nWidth;
}
+
void CFDE_TxtEdtPage::NormalizePt2Rect(CFX_PointF& ptF,
const CFX_RectF& rtF,
FX_FLOAT fTolerance) const {
diff --git a/xfa/fee/fde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h
index 81f29fed49..8be940f556 100644
--- a/xfa/fee/fde_txtedtpage.h
+++ b/xfa/fde/cfde_txtedtpage.h
@@ -4,62 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_FDE_TXTEDTPAGE_H_
-#define XFA_FEE_FDE_TXTEDTPAGE_H_
+#ifndef XFA_FDE_CFDE_TXTEDTPAGE_H_
+#define XFA_FDE_CFDE_TXTEDTPAGE_H_
-#include <memory>
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_string.h"
-#include "xfa/fde/fde_visualset.h"
-#include "xfa/fee/ifde_txtedtpage.h"
-#include "xfa/fgas/crt/fgas_utils.h"
-
-class IFX_CharIter;
-class CFDE_TxtEdtEngine;
-class CFDE_TxtEdtPage;
-class CFDE_TxtEdtParag;
-
-enum FDE_TXTEDT_CHARTYPE {
- FDE_TXTEDT_CHARTYPE_Unknown = 0,
- FDE_TXTEDT_CHARTYPE_Tab,
- FDE_TXTEDT_CHARTYPE_Space,
- FDE_TXTEDT_CHARTYPE_Punctuation,
- FDE_TXTEDT_CHARTYPE_LineBreak,
- FDE_TXTEDT_CHARTYPE_Number,
- FDE_TXTEDT_CHARTYPE_Char,
- FDE_TXTEDT_CHARTYPE_CJK,
-};
-
-inline FDE_TXTEDT_CHARTYPE FDE_GetEditSelCharType(FX_WCHAR wChar) {
- if (wChar == 0x9) {
- return FDE_TXTEDT_CHARTYPE_Tab;
- } else if (wChar == 0x20 || wChar == 0xA0) {
- return FDE_TXTEDT_CHARTYPE_Space;
- } else if (wChar == 0x9 || wChar == 0x20 || wChar == 0xA0 ||
- (wChar >= L'!' && wChar <= L'/') ||
- (wChar >= L':' && wChar <= L'@') ||
- (wChar >= L'[' && wChar <= L'^') ||
- (wChar >= L'{' && wChar <= L'~') || wChar == 0x60) {
- return FDE_TXTEDT_CHARTYPE_Punctuation;
- } else if (wChar == 0x0a || wChar == 0x0d) {
- return FDE_TXTEDT_CHARTYPE_LineBreak;
- } else if (wChar >= '0' && wChar <= '9') {
- return FDE_TXTEDT_CHARTYPE_Number;
- } else if ((wChar >= 0x2e80 && wChar <= 0x2eff) ||
- (wChar >= 0x3000 && wChar <= 0x303f) ||
- (wChar >= 0x31c0 && wChar <= 0x31ef) ||
- (wChar >= 0x3200 && wChar <= 0x32ff) ||
- (wChar >= 0x3300 && wChar <= 0x33ff) ||
- (wChar >= 0x3400 && wChar <= 0x4dbf) ||
- (wChar >= 0x4e00 && wChar <= 0x9fff) ||
- (wChar >= 0xf900 && wChar <= 0xfaff) ||
- (wChar >= 0xfe30 && wChar <= 0xfe4f)) {
- return FDE_TXTEDT_CHARTYPE_CJK;
- } else {
- return FDE_TXTEDT_CHARTYPE_Char;
- }
-}
+#include "xfa/fde/ifde_txtedtpage.h"
+#include "xfa/fde/ifx_chariter.h"
struct FDE_TEXTEDITPIECE {
int32_t nStart;
@@ -70,32 +19,9 @@ struct FDE_TEXTEDITPIECE {
};
typedef CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> CFDE_TXTEDTPieceMassArray;
-class CFDE_TxtEdtTextSet : public IFDE_TextSet {
- public:
- CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage);
- ~CFDE_TxtEdtTextSet();
-
- virtual FDE_VISUALOBJTYPE GetType();
- virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox);
- virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix);
- virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt);
- virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt);
- virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText);
- virtual IFX_Font* GetFont(FDE_HVISUALOBJ hText);
- virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText);
- virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText);
- virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL);
- virtual int32_t GetCharRects(FDE_HVISUALOBJ hText, CFX_RectFArray& rtArray);
- virtual int32_t GetCharRects_Impl(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray,
- FX_BOOL bBBox = FALSE);
-
- private:
- CFDE_TxtEdtPage* m_pPage;
-};
+class CFDE_TxtEdtEngine;
+class CFDE_TxtEdtParag;
+class CFDE_TxtEdtTextSet;
class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
public:
@@ -167,4 +93,4 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
int32_t* m_pCharWidth;
};
-#endif // XFA_FEE_FDE_TXTEDTPAGE_H_
+#endif // XFA_FDE_CFDE_TXTEDTPAGE_H_
diff --git a/xfa/fee/fde_txtedtparag.cpp b/xfa/fde/cfde_txtedtparag.cpp
index 4f5b5a15df..63e9a939b5 100644
--- a/xfa/fee/fde_txtedtparag.cpp
+++ b/xfa/fde/cfde_txtedtparag.cpp
@@ -4,13 +4,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fee/fde_txtedtparag.h"
+#include "xfa/fde/cfde_txtedtparag.h"
-#include "xfa/fee/fde_txtedtbuf.h"
-#include "xfa/fee/fde_txtedtengine.h"
-#include "xfa/fee/fx_wordbreak/fx_wordbreak.h"
-#include "xfa/fee/ifde_txtedtengine.h"
+#include "xfa/fde/cfde_txtedtbuf.h"
+#include "xfa/fde/cfde_txtedtbufiter.h"
+#include "xfa/fde/cfde_txtedtengine.h"
+#include "xfa/fde/ifde_txtedtengine.h"
#include "xfa/fgas/layout/fgas_textbreak.h"
+#include "xfa/fde/ifx_chariter.h"
CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine)
: m_nCharStart(0),
@@ -20,11 +21,12 @@ CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine)
m_pEngine(pEngine) {
ASSERT(m_pEngine);
}
+
CFDE_TxtEdtParag::~CFDE_TxtEdtParag() {
- if (m_lpData != NULL) {
+ if (m_lpData)
FX_Free(m_lpData);
- }
}
+
void CFDE_TxtEdtParag::LoadParag() {
if (m_lpData != NULL) {
((int32_t*)m_lpData)[0]++;
@@ -89,6 +91,7 @@ void CFDE_TxtEdtParag::LoadParag() {
}
LineBaseArr.RemoveAll();
}
+
void CFDE_TxtEdtParag::UnloadParag() {
ASSERT(m_lpData != NULL);
((int32_t*)m_lpData)[0]--;
@@ -98,6 +101,7 @@ void CFDE_TxtEdtParag::UnloadParag() {
m_lpData = NULL;
}
}
+
void CFDE_TxtEdtParag::CalcLines() {
CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak();
CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf();
@@ -133,6 +137,7 @@ void CFDE_TxtEdtParag::CalcLines() {
pTxtBreak->ClearBreakPieces();
m_nLineCount = nCount;
}
+
void CFDE_TxtEdtParag::GetLineRange(int32_t nLineIndex,
int32_t& nStart,
int32_t& nCount) const {
diff --git a/xfa/fee/fde_txtedtparag.h b/xfa/fde/cfde_txtedtparag.h
index 24ecbc7bf0..74eaaff088 100644
--- a/xfa/fee/fde_txtedtparag.h
+++ b/xfa/fde/cfde_txtedtparag.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_FDE_TXTEDTPARAG_H_
-#define XFA_FEE_FDE_TXTEDTPARAG_H_
+#ifndef XFA_FDE_CFDE_TXTEDTPARAG_H_
+#define XFA_FDE_CFDE_TXTEDTPARAG_H_
#include <stdint.h>
@@ -40,4 +40,4 @@ class CFDE_TxtEdtParag {
CFDE_TxtEdtEngine* m_pEngine;
};
-#endif // XFA_FEE_FDE_TXTEDTPARAG_H_
+#endif // XFA_FDE_CFDE_TXTEDTPARAG_H_
diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp
new file mode 100644
index 0000000000..a2a6c225ba
--- /dev/null
+++ b/xfa/fde/cfde_txtedttextset.cpp
@@ -0,0 +1,129 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/cfde_txtedttextset.h"
+
+#include "xfa/fde/cfde_txtedtengine.h"
+#include "xfa/fde/cfde_txtedtpage.h"
+
+CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage)
+ : m_pPage(pPage) {}
+
+CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {}
+
+FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() {
+ return FDE_VISUALOBJ_Text;
+}
+
+FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj,
+ CFX_RectF& bbox) {
+ return FALSE;
+}
+
+FX_BOOL CFDE_TxtEdtTextSet::GetMatrix(FDE_HVISUALOBJ hVisualObj,
+ CFX_Matrix& matrix) {
+ return FALSE;
+}
+
+FX_BOOL CFDE_TxtEdtTextSet::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
+ rt = reinterpret_cast<const FDE_TEXTEDITPIECE*>(hVisualObj)->rtPiece;
+ return TRUE;
+}
+
+FX_BOOL CFDE_TxtEdtTextSet::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
+ return FALSE;
+}
+
+int32_t CFDE_TxtEdtTextSet::GetString(FDE_HVISUALOBJ hText,
+ CFX_WideString& wsText) {
+ const FDE_TEXTEDITPIECE* pPiece =
+ reinterpret_cast<const FDE_TEXTEDITPIECE*>(hText);
+ FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount);
+ for (int32_t i = 0; i < pPiece->nCount; i++) {
+ pBuffer[i] = m_pPage->GetChar((void*)hText, i);
+ }
+ wsText.ReleaseBuffer(pPiece->nCount);
+ return pPiece->nCount;
+}
+
+IFX_Font* CFDE_TxtEdtTextSet::GetFont(FDE_HVISUALOBJ hText) {
+ return m_pPage->GetEngine()->GetEditParams()->pFont;
+}
+
+FX_FLOAT CFDE_TxtEdtTextSet::GetFontSize(FDE_HVISUALOBJ hText) {
+ return m_pPage->GetEngine()->GetEditParams()->fFontSize;
+}
+
+FX_ARGB CFDE_TxtEdtTextSet::GetFontColor(FDE_HVISUALOBJ hText) {
+ return m_pPage->GetEngine()->GetEditParams()->dwFontColor;
+}
+
+int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText,
+ FXTEXT_CHARPOS* pCharPos,
+ FX_BOOL bCharCode,
+ CFX_WideString* pWSForms) {
+ if (!hText)
+ return 0;
+
+ const FDE_TEXTEDITPIECE* pPiece =
+ reinterpret_cast<const FDE_TEXTEDITPIECE*>(hText);
+ int32_t nLength = pPiece->nCount;
+ if (nLength < 1)
+ return 0;
+
+ CFDE_TxtEdtEngine* pEngine =
+ static_cast<CFDE_TxtEdtEngine*>(m_pPage->GetEngine());
+ const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams();
+ CFX_TxtBreak* pBreak = pEngine->GetTextBreak();
+ uint32_t dwLayoutStyle = pBreak->GetLayoutStyles();
+ FX_TXTRUN tr;
+ tr.pAccess = m_pPage;
+ tr.pIdentity = (void*)hText;
+ tr.iLength = nLength;
+ tr.pFont = pTextParams->pFont;
+ tr.fFontSize = pTextParams->fFontSize;
+ tr.dwStyles = dwLayoutStyle;
+ tr.iCharRotation = pTextParams->nCharRotation;
+ tr.dwCharStyles = pPiece->dwCharStyles;
+ tr.pRect = &(pPiece->rtPiece);
+ tr.wLineBreakChar = pTextParams->wLineBreakChar;
+ return pBreak->GetDisplayPos(&tr, pCharPos, bCharCode, pWSForms);
+}
+
+int32_t CFDE_TxtEdtTextSet::GetCharRects(FDE_HVISUALOBJ hText,
+ CFX_RectFArray& rtArray) {
+ return GetCharRects_Impl(hText, rtArray);
+}
+
+int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bBBox) {
+ if (!hText)
+ return 0;
+
+ const FDE_TEXTEDITPIECE* pPiece =
+ reinterpret_cast<const FDE_TEXTEDITPIECE*>(hText);
+ CFDE_TxtEdtEngine* pEngine =
+ static_cast<CFDE_TxtEdtEngine*>(m_pPage->GetEngine());
+ int32_t nLength = pPiece->nCount;
+ if (nLength < 1)
+ return 0;
+
+ const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams();
+ uint32_t dwLayoutStyle = pEngine->GetTextBreak()->GetLayoutStyles();
+ FX_TXTRUN tr;
+ tr.pAccess = m_pPage;
+ tr.pIdentity = (void*)hText;
+ tr.iLength = nLength;
+ tr.pFont = pTextParams->pFont;
+ tr.fFontSize = pTextParams->fFontSize;
+ tr.dwStyles = dwLayoutStyle;
+ tr.iCharRotation = pTextParams->nCharRotation;
+ tr.dwCharStyles = pPiece->dwCharStyles;
+ tr.pRect = &(pPiece->rtPiece);
+ tr.wLineBreakChar = pTextParams->wLineBreakChar;
+ return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox);
+}
diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h
new file mode 100644
index 0000000000..efd0a18604
--- /dev/null
+++ b/xfa/fde/cfde_txtedttextset.h
@@ -0,0 +1,41 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFDE_TXTEDTTEXTSET_H_
+#define XFA_FDE_CFDE_TXTEDTTEXTSET_H_
+
+#include "xfa/fde/fde_visualset.h"
+
+class CFDE_TxtEdtPage;
+
+class CFDE_TxtEdtTextSet : public IFDE_TextSet {
+ public:
+ explicit CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage);
+ ~CFDE_TxtEdtTextSet() override;
+
+ FDE_VISUALOBJTYPE GetType() override;
+ FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) override;
+ FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) override;
+ FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
+ FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
+ int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText) override;
+ IFX_Font* GetFont(FDE_HVISUALOBJ hText) override;
+ FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText) override;
+ FX_ARGB GetFontColor(FDE_HVISUALOBJ hText) override;
+ int32_t GetDisplayPos(FDE_HVISUALOBJ hText,
+ FXTEXT_CHARPOS* pCharPos,
+ FX_BOOL bCharCode = FALSE,
+ CFX_WideString* pWSForms = NULL) override;
+ int32_t GetCharRects(FDE_HVISUALOBJ hText, CFX_RectFArray& rtArray) override;
+ int32_t GetCharRects_Impl(FDE_HVISUALOBJ hText,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bBBox = FALSE);
+
+ private:
+ CFDE_TxtEdtPage* const m_pPage;
+};
+
+#endif // XFA_FDE_CFDE_TXTEDTTEXTSET_H_
diff --git a/xfa/fde/cfx_chariter.cpp b/xfa/fde/cfx_chariter.cpp
new file mode 100644
index 0000000000..d51fb0868f
--- /dev/null
+++ b/xfa/fde/cfx_chariter.cpp
@@ -0,0 +1,51 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/cfx_chariter.h"
+
+CFX_CharIter::CFX_CharIter(const CFX_WideString& wsText)
+ : m_wsText(wsText), m_nIndex(0) {
+ ASSERT(!wsText.IsEmpty());
+}
+
+CFX_CharIter::~CFX_CharIter() {}
+
+FX_BOOL CFX_CharIter::Next(FX_BOOL bPrev) {
+ if (bPrev) {
+ if (m_nIndex <= 0)
+ return FALSE;
+ m_nIndex--;
+ } else {
+ if (m_nIndex + 1 >= m_wsText.GetLength())
+ return FALSE;
+ m_nIndex++;
+ }
+ return TRUE;
+}
+
+FX_WCHAR CFX_CharIter::GetChar() {
+ return m_wsText.GetAt(m_nIndex);
+}
+
+void CFX_CharIter::SetAt(int32_t nIndex) {
+ if (nIndex < 0 || nIndex >= m_wsText.GetLength())
+ return;
+ m_nIndex = nIndex;
+}
+
+int32_t CFX_CharIter::GetAt() const {
+ return m_nIndex;
+}
+
+FX_BOOL CFX_CharIter::IsEOF(FX_BOOL bTail) const {
+ return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0);
+}
+
+IFX_CharIter* CFX_CharIter::Clone() {
+ CFX_CharIter* pIter = new CFX_CharIter(m_wsText);
+ pIter->m_nIndex = m_nIndex;
+ return pIter;
+}
diff --git a/xfa/fde/cfx_chariter.h b/xfa/fde/cfx_chariter.h
new file mode 100644
index 0000000000..ba9d84cb39
--- /dev/null
+++ b/xfa/fde/cfx_chariter.h
@@ -0,0 +1,31 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFX_CHARITER_H_
+#define XFA_FDE_CFX_CHARITER_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fde/ifx_chariter.h"
+
+class CFX_CharIter : public IFX_CharIter {
+ public:
+ explicit CFX_CharIter(const CFX_WideString& wsText);
+ ~CFX_CharIter() override;
+
+ FX_BOOL Next(FX_BOOL bPrev = FALSE) override;
+ FX_WCHAR GetChar() override;
+ void SetAt(int32_t nIndex) override;
+ int32_t GetAt() const override;
+ FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override;
+ IFX_CharIter* Clone() override;
+
+ private:
+ const CFX_WideString& m_wsText;
+ int32_t m_nIndex;
+};
+
+#endif // XFA_FDE_CFX_CHARITER_H_
diff --git a/xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp b/xfa/fde/cfx_wordbreak.cpp
index b632d5fafc..5b220df60e 100644
--- a/xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp
+++ b/xfa/fde/cfx_wordbreak.cpp
@@ -4,7 +4,27 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fee/fx_wordbreak/fx_wordbreak_impl.h"
+#include "xfa/fde/cfx_wordbreak.h"
+
+#include "xfa/fde/cfx_chariter.h"
+
+namespace {
+
+enum FX_WordBreakProp {
+ FX_WordBreakProp_None = 0,
+ FX_WordBreakProp_CR,
+ FX_WordBreakProp_LF,
+ FX_WordBreakProp_NewLine,
+ FX_WordBreakProp_Extend,
+ FX_WordBreakProp_Format,
+ FX_WordBreakProp_KataKana,
+ FX_WordBreakProp_ALetter,
+ FX_WordBreakProp_MidLetter,
+ FX_WordBreakProp_MidNum,
+ FX_WordBreakProp_MidNumLet,
+ FX_WordBreakProp_Numberic,
+ FX_WordBreakProp_ExtendNumLet,
+};
const uint16_t gs_FX_WordBreak_Table[16] = {
0xFFFF, 0xFFF9, 0xFFFB, 0xFFFB, 0xFFFB, 0xFFFB, 0xEFBB, 0xE77B,
@@ -2746,3 +2766,182 @@ const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1] =
0x00, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x00, 0x00,
};
+
+FX_WordBreakProp GetWordBreakProperty(FX_WCHAR wcCodePoint) {
+ uint32_t dwProperty =
+ (uint32_t)gs_FX_WordBreak_CodePointProperties[wcCodePoint >> 1];
+ return (FX_WordBreakProp)(((wcCodePoint)&1) ? (dwProperty & 0x0F)
+ : (dwProperty >> 4));
+}
+
+} // namespace
+
+CFX_WordBreak::CFX_WordBreak() {}
+
+CFX_WordBreak::~CFX_WordBreak() {}
+
+void CFX_WordBreak::Attach(IFX_CharIter* pIter) {
+ ASSERT(pIter);
+ m_pCurIter.reset(pIter);
+}
+
+void CFX_WordBreak::Attach(const CFX_WideString& wsText) {
+ m_pCurIter.reset(new CFX_CharIter(wsText));
+}
+
+FX_BOOL CFX_WordBreak::Next(FX_BOOL bPrev) {
+ std::unique_ptr<IFX_CharIter> pIter(
+ (bPrev ? m_pPreIter : m_pCurIter)->Clone());
+ if (pIter->IsEOF(!bPrev))
+ return FALSE;
+
+ pIter->Next(bPrev);
+ if (!FindNextBreakPos(pIter.get(), bPrev, TRUE))
+ return FALSE;
+
+ if (bPrev) {
+ m_pCurIter = std::move(m_pPreIter);
+ m_pCurIter->Next(TRUE);
+ m_pPreIter = std::move(pIter);
+ } else {
+ m_pPreIter = std::move(m_pCurIter);
+ m_pPreIter->Next();
+ m_pCurIter = std::move(pIter);
+ }
+ return TRUE;
+}
+
+void CFX_WordBreak::SetAt(int32_t nIndex) {
+ m_pPreIter.reset();
+ m_pCurIter->SetAt(nIndex);
+ FindNextBreakPos(m_pCurIter.get(), TRUE, FALSE);
+ m_pPreIter = std::move(m_pCurIter);
+ m_pCurIter.reset(m_pPreIter->Clone());
+ FindNextBreakPos(m_pCurIter.get(), FALSE, FALSE);
+}
+
+int32_t CFX_WordBreak::GetWordPos() const {
+ return m_pPreIter->GetAt();
+}
+
+int32_t CFX_WordBreak::GetWordLength() const {
+ return m_pCurIter->GetAt() - m_pPreIter->GetAt() + 1;
+}
+
+void CFX_WordBreak::GetWord(CFX_WideString& wsWord) const {
+ int32_t nWordLength = GetWordLength();
+ if (nWordLength <= 0) {
+ return;
+ }
+ FX_WCHAR* lpBuf = wsWord.GetBuffer(nWordLength);
+ std::unique_ptr<IFX_CharIter> pTempIter(m_pPreIter->Clone());
+ int32_t i = 0;
+ while (pTempIter->GetAt() <= m_pCurIter->GetAt()) {
+ lpBuf[i++] = pTempIter->GetChar();
+ if (!pTempIter->Next())
+ break;
+ }
+ wsWord.ReleaseBuffer(nWordLength);
+}
+
+FX_BOOL CFX_WordBreak::IsEOF(FX_BOOL bTail) const {
+ return m_pCurIter->IsEOF(bTail);
+}
+
+FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter,
+ FX_BOOL bPrev,
+ FX_BOOL bFromNext) {
+ FX_WordBreakProp ePreType = FX_WordBreakProp_None;
+ FX_WordBreakProp eCurType = FX_WordBreakProp_None;
+ FX_WordBreakProp eNextType = FX_WordBreakProp_None;
+ if (pIter->IsEOF(!bPrev)) {
+ return TRUE;
+ }
+ if (!(bFromNext || pIter->IsEOF(bPrev))) {
+ pIter->Next(!bPrev);
+ FX_WCHAR wcTemp = pIter->GetChar();
+ ePreType = GetWordBreakProperty(wcTemp);
+ pIter->Next(bPrev);
+ }
+ FX_WCHAR wcTemp = pIter->GetChar();
+ eCurType = GetWordBreakProperty(wcTemp);
+ FX_BOOL bFirst = TRUE;
+ do {
+ pIter->Next(bPrev);
+ FX_WCHAR wcTemp = pIter->GetChar();
+ eNextType = GetWordBreakProperty(wcTemp);
+ uint16_t wBreak =
+ gs_FX_WordBreak_Table[eCurType] & ((uint16_t)(1 << eNextType));
+ if (wBreak) {
+ if (pIter->IsEOF(!bPrev)) {
+ pIter->Next(!bPrev);
+ return TRUE;
+ }
+ if (bFirst) {
+ int32_t nFlags = 0;
+ if (eCurType == FX_WordBreakProp_MidLetter) {
+ if (eNextType == FX_WordBreakProp_ALetter) {
+ nFlags = 1;
+ }
+ } else if (eCurType == FX_WordBreakProp_MidNum) {
+ if (eNextType == FX_WordBreakProp_Numberic) {
+ nFlags = 2;
+ }
+ } else if (eCurType == FX_WordBreakProp_MidNumLet) {
+ if (eNextType == FX_WordBreakProp_ALetter) {
+ nFlags = 1;
+ } else if (eNextType == FX_WordBreakProp_Numberic) {
+ nFlags = 2;
+ }
+ }
+ if (nFlags > 0) {
+ ASSERT(nFlags <= 2);
+ if (!((nFlags == 1 && ePreType == FX_WordBreakProp_ALetter) ||
+ (nFlags == 2 && ePreType == FX_WordBreakProp_Numberic))) {
+ pIter->Next(!bPrev);
+ return TRUE;
+ }
+ pIter->Next(bPrev);
+ wBreak = FALSE;
+ }
+ bFirst = FALSE;
+ }
+ if (wBreak) {
+ int32_t nFlags = 0;
+ if (eNextType == FX_WordBreakProp_MidLetter) {
+ if (eCurType == FX_WordBreakProp_ALetter) {
+ nFlags = 1;
+ }
+ } else if (eNextType == FX_WordBreakProp_MidNum) {
+ if (eCurType == FX_WordBreakProp_Numberic) {
+ nFlags = 2;
+ }
+ } else if (eNextType == FX_WordBreakProp_MidNumLet) {
+ if (eCurType == FX_WordBreakProp_ALetter) {
+ nFlags = 1;
+ } else if (eCurType == FX_WordBreakProp_Numberic) {
+ nFlags = 2;
+ }
+ }
+ if (nFlags <= 0) {
+ pIter->Next(!bPrev);
+ return TRUE;
+ }
+ ASSERT(nFlags <= 2);
+ pIter->Next(bPrev);
+ wcTemp = pIter->GetChar();
+ eNextType = (FX_WordBreakProp)GetWordBreakProperty(wcTemp);
+ if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) ||
+ (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) {
+ pIter->Next(!bPrev);
+ pIter->Next(!bPrev);
+ return TRUE;
+ }
+ }
+ }
+ ePreType = eCurType;
+ eCurType = eNextType;
+ bFirst = FALSE;
+ } while (!pIter->IsEOF(!bPrev));
+ return TRUE;
+}
diff --git a/xfa/fee/fx_wordbreak/fx_wordbreak.h b/xfa/fde/cfx_wordbreak.h
index e1b1787579..2465c5509e 100644
--- a/xfa/fee/fx_wordbreak/fx_wordbreak.h
+++ b/xfa/fde/cfx_wordbreak.h
@@ -4,31 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_
-#define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_
+#ifndef XFA_FDE_CFX_WORDBREAK_H_
+#define XFA_FDE_CFX_WORDBREAK_H_
#include <memory>
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fee/ifde_txtedtengine.h"
-class CFX_CharIter : public IFX_CharIter {
- public:
- explicit CFX_CharIter(const CFX_WideString& wsText);
- ~CFX_CharIter() override;
-
- FX_BOOL Next(FX_BOOL bPrev = FALSE) override;
- FX_WCHAR GetChar() override;
- void SetAt(int32_t nIndex) override;
- int32_t GetAt() const override;
- FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override;
- IFX_CharIter* Clone() override;
-
- private:
- const CFX_WideString& m_wsText;
- int32_t m_nIndex;
-};
+class IFX_CharIter;
class CFX_WordBreak {
public:
@@ -54,4 +38,4 @@ class CFX_WordBreak {
std::unique_ptr<IFX_CharIter> m_pCurIter;
};
-#endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_
+#endif // XFA_FDE_CFX_WORDBREAK_H_
diff --git a/xfa/fde/ifde_txtedtdorecord.h b/xfa/fde/ifde_txtedtdorecord.h
new file mode 100644
index 0000000000..5c5d595e4e
--- /dev/null
+++ b/xfa/fde/ifde_txtedtdorecord.h
@@ -0,0 +1,20 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_IFDE_TXTEDTDORECORD_H_
+#define XFA_FDE_IFDE_TXTEDTDORECORD_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class IFDE_TxtEdtDoRecord {
+ public:
+ virtual ~IFDE_TxtEdtDoRecord() {}
+
+ virtual FX_BOOL Redo() const = 0;
+ virtual FX_BOOL Undo() const = 0;
+};
+
+#endif // XFA_FDE_IFDE_TXTEDTDORECORD_H_
diff --git a/xfa/fee/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h
index 54e96b8c8f..0af0e75497 100644
--- a/xfa/fee/ifde_txtedtengine.h
+++ b/xfa/fde/ifde_txtedtengine.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_IFDE_TXTEDTENGINE_H_
-#define XFA_FEE_IFDE_TXTEDTENGINE_H_
+#ifndef XFA_FDE_IFDE_TXTEDTENGINE_H_
+#define XFA_FDE_IFDE_TXTEDTENGINE_H_
#include "core/fxge/include/fx_dib.h"
#include "xfa/fgas/font/fgas_font.h"
@@ -139,16 +139,4 @@ struct FDE_TXTEDT_TEXTCHANGE_INFO {
CFX_WideString wsPrevText;
};
-class IFX_CharIter {
- public:
- virtual ~IFX_CharIter() {}
-
- virtual FX_BOOL Next(FX_BOOL bPrev = FALSE) = 0;
- virtual FX_WCHAR GetChar() = 0;
- virtual void SetAt(int32_t nIndex) = 0;
- virtual int32_t GetAt() const = 0;
- virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const = 0;
- virtual IFX_CharIter* Clone() = 0;
-};
-
-#endif // XFA_FEE_IFDE_TXTEDTENGINE_H_
+#endif // XFA_FDE_IFDE_TXTEDTENGINE_H_
diff --git a/xfa/fee/ifde_txtedtpage.h b/xfa/fde/ifde_txtedtpage.h
index 695b442b99..7dddea2709 100644
--- a/xfa/fee/ifde_txtedtpage.h
+++ b/xfa/fde/ifde_txtedtpage.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FEE_IFDE_TXTEDTPAGE_H_
-#define XFA_FEE_IFDE_TXTEDTPAGE_H_
+#ifndef XFA_FDE_IFDE_TXTEDTPAGE_H_
+#define XFA_FDE_IFDE_TXTEDTPAGE_H_
#include "core/fxge/include/fx_ge.h"
#include "xfa/fde/fde_visualset.h"
@@ -40,4 +40,4 @@ class IFDE_TxtEdtPage : public IFDE_CanvasSet, public IFX_TxtAccess {
virtual const CFX_RectF& GetContentsBox() = 0;
};
-#endif // XFA_FEE_IFDE_TXTEDTPAGE_H_
+#endif // XFA_FDE_IFDE_TXTEDTPAGE_H_
diff --git a/xfa/fde/ifx_chariter.h b/xfa/fde/ifx_chariter.h
new file mode 100644
index 0000000000..44a9ba42f6
--- /dev/null
+++ b/xfa/fde/ifx_chariter.h
@@ -0,0 +1,24 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_IFX_CHARITER_H_
+#define XFA_FDE_IFX_CHARITER_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class IFX_CharIter {
+ public:
+ virtual ~IFX_CharIter() {}
+
+ virtual FX_BOOL Next(FX_BOOL bPrev = FALSE) = 0;
+ virtual FX_WCHAR GetChar() = 0;
+ virtual void SetAt(int32_t nIndex) = 0;
+ virtual int32_t GetAt() const = 0;
+ virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const = 0;
+ virtual IFX_CharIter* Clone() = 0;
+};
+
+#endif // XFA_FDE_IFX_CHARITER_H_
diff --git a/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp b/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp
deleted file mode 100644
index eda5368afb..0000000000
--- a/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fee/fx_wordbreak/fx_wordbreak_impl.h"
-
-FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint) {
- uint32_t dwProperty =
- (uint32_t)gs_FX_WordBreak_CodePointProperties[wcCodePoint >> 1];
- return (FX_WordBreakProp)(((wcCodePoint)&1) ? (dwProperty & 0x0F)
- : (dwProperty >> 4));
-}
-
-CFX_CharIter::CFX_CharIter(const CFX_WideString& wsText)
- : m_wsText(wsText), m_nIndex(0) {
- ASSERT(!wsText.IsEmpty());
-}
-
-CFX_CharIter::~CFX_CharIter() {}
-
-FX_BOOL CFX_CharIter::Next(FX_BOOL bPrev) {
- if (bPrev) {
- if (m_nIndex <= 0) {
- return FALSE;
- }
- m_nIndex--;
- } else {
- if (m_nIndex + 1 >= m_wsText.GetLength()) {
- return FALSE;
- }
- m_nIndex++;
- }
- return TRUE;
-}
-FX_WCHAR CFX_CharIter::GetChar() {
- return m_wsText.GetAt(m_nIndex);
-}
-void CFX_CharIter::SetAt(int32_t nIndex) {
- if (nIndex < 0 || nIndex >= m_wsText.GetLength()) {
- return;
- }
- m_nIndex = nIndex;
-}
-int32_t CFX_CharIter::GetAt() const {
- return m_nIndex;
-}
-FX_BOOL CFX_CharIter::IsEOF(FX_BOOL bTail) const {
- return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0);
-}
-IFX_CharIter* CFX_CharIter::Clone() {
- CFX_CharIter* pIter = new CFX_CharIter(m_wsText);
- pIter->m_nIndex = m_nIndex;
- return pIter;
-}
-
-CFX_WordBreak::CFX_WordBreak() {}
-
-CFX_WordBreak::~CFX_WordBreak() {}
-
-void CFX_WordBreak::Attach(IFX_CharIter* pIter) {
- ASSERT(pIter);
- m_pCurIter.reset(pIter);
-}
-void CFX_WordBreak::Attach(const CFX_WideString& wsText) {
- m_pCurIter.reset(new CFX_CharIter(wsText));
-}
-FX_BOOL CFX_WordBreak::Next(FX_BOOL bPrev) {
- std::unique_ptr<IFX_CharIter> pIter(
- (bPrev ? m_pPreIter : m_pCurIter)->Clone());
- if (pIter->IsEOF(!bPrev))
- return FALSE;
-
- pIter->Next(bPrev);
- if (!FindNextBreakPos(pIter.get(), bPrev, TRUE))
- return FALSE;
-
- if (bPrev) {
- m_pCurIter = std::move(m_pPreIter);
- m_pCurIter->Next(TRUE);
- m_pPreIter = std::move(pIter);
- } else {
- m_pPreIter = std::move(m_pCurIter);
- m_pPreIter->Next();
- m_pCurIter = std::move(pIter);
- }
- return TRUE;
-}
-void CFX_WordBreak::SetAt(int32_t nIndex) {
- m_pPreIter.reset();
- m_pCurIter->SetAt(nIndex);
- FindNextBreakPos(m_pCurIter.get(), TRUE, FALSE);
- m_pPreIter = std::move(m_pCurIter);
- m_pCurIter.reset(m_pPreIter->Clone());
- FindNextBreakPos(m_pCurIter.get(), FALSE, FALSE);
-}
-int32_t CFX_WordBreak::GetWordPos() const {
- return m_pPreIter->GetAt();
-}
-int32_t CFX_WordBreak::GetWordLength() const {
- return m_pCurIter->GetAt() - m_pPreIter->GetAt() + 1;
-}
-void CFX_WordBreak::GetWord(CFX_WideString& wsWord) const {
- int32_t nWordLength = GetWordLength();
- if (nWordLength <= 0) {
- return;
- }
- FX_WCHAR* lpBuf = wsWord.GetBuffer(nWordLength);
- std::unique_ptr<IFX_CharIter> pTempIter(m_pPreIter->Clone());
- int32_t i = 0;
- while (pTempIter->GetAt() <= m_pCurIter->GetAt()) {
- lpBuf[i++] = pTempIter->GetChar();
- if (!pTempIter->Next())
- break;
- }
- wsWord.ReleaseBuffer(nWordLength);
-}
-FX_BOOL CFX_WordBreak::IsEOF(FX_BOOL bTail) const {
- return m_pCurIter->IsEOF(bTail);
-}
-FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter,
- FX_BOOL bPrev,
- FX_BOOL bFromNext) {
- FX_WordBreakProp ePreType = FX_WordBreakProp_None;
- FX_WordBreakProp eCurType = FX_WordBreakProp_None;
- FX_WordBreakProp eNextType = FX_WordBreakProp_None;
- if (pIter->IsEOF(!bPrev)) {
- return TRUE;
- }
- if (!(bFromNext || pIter->IsEOF(bPrev))) {
- pIter->Next(!bPrev);
- FX_WCHAR wcTemp = pIter->GetChar();
- ePreType = FX_GetWordBreakProperty(wcTemp);
- pIter->Next(bPrev);
- }
- FX_WCHAR wcTemp = pIter->GetChar();
- eCurType = FX_GetWordBreakProperty(wcTemp);
- FX_BOOL bFirst = TRUE;
- do {
- pIter->Next(bPrev);
- FX_WCHAR wcTemp = pIter->GetChar();
- eNextType = FX_GetWordBreakProperty(wcTemp);
- uint16_t wBreak =
- gs_FX_WordBreak_Table[eCurType] & ((uint16_t)(1 << eNextType));
- if (wBreak) {
- if (pIter->IsEOF(!bPrev)) {
- pIter->Next(!bPrev);
- return TRUE;
- }
- if (bFirst) {
- int32_t nFlags = 0;
- if (eCurType == FX_WordBreakProp_MidLetter) {
- if (eNextType == FX_WordBreakProp_ALetter) {
- nFlags = 1;
- }
- } else if (eCurType == FX_WordBreakProp_MidNum) {
- if (eNextType == FX_WordBreakProp_Numberic) {
- nFlags = 2;
- }
- } else if (eCurType == FX_WordBreakProp_MidNumLet) {
- if (eNextType == FX_WordBreakProp_ALetter) {
- nFlags = 1;
- } else if (eNextType == FX_WordBreakProp_Numberic) {
- nFlags = 2;
- }
- }
- if (nFlags > 0) {
- ASSERT(nFlags <= 2);
- if (!((nFlags == 1 && ePreType == FX_WordBreakProp_ALetter) ||
- (nFlags == 2 && ePreType == FX_WordBreakProp_Numberic))) {
- pIter->Next(!bPrev);
- return TRUE;
- }
- pIter->Next(bPrev);
- wBreak = FALSE;
- }
- bFirst = FALSE;
- }
- if (wBreak) {
- int32_t nFlags = 0;
- if (eNextType == FX_WordBreakProp_MidLetter) {
- if (eCurType == FX_WordBreakProp_ALetter) {
- nFlags = 1;
- }
- } else if (eNextType == FX_WordBreakProp_MidNum) {
- if (eCurType == FX_WordBreakProp_Numberic) {
- nFlags = 2;
- }
- } else if (eNextType == FX_WordBreakProp_MidNumLet) {
- if (eCurType == FX_WordBreakProp_ALetter) {
- nFlags = 1;
- } else if (eCurType == FX_WordBreakProp_Numberic) {
- nFlags = 2;
- }
- }
- if (nFlags <= 0) {
- pIter->Next(!bPrev);
- return TRUE;
- }
- ASSERT(nFlags <= 2);
- pIter->Next(bPrev);
- wcTemp = pIter->GetChar();
- eNextType = (FX_WordBreakProp)FX_GetWordBreakProperty(wcTemp);
- if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) ||
- (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) {
- pIter->Next(!bPrev);
- pIter->Next(!bPrev);
- return TRUE;
- }
- }
- }
- ePreType = eCurType;
- eCurType = eNextType;
- bFirst = FALSE;
- } while (!pIter->IsEOF(!bPrev));
- return TRUE;
-}
diff --git a/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h b/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h
deleted file mode 100644
index 5cbd185602..0000000000
--- a/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_
-#define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_
-
-#include <cstdint>
-
-#include "core/fxcrt/include/fx_string.h"
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fee/fx_wordbreak/fx_wordbreak.h"
-#include "xfa/fee/fx_wordbreak/fx_wordbreak_impl.h"
-#include "xfa/fee/ifde_txtedtengine.h"
-
-extern const uint16_t gs_FX_WordBreak_Table[16];
-extern const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1];
-enum FX_WordBreakProp {
- FX_WordBreakProp_None = 0,
- FX_WordBreakProp_CR,
- FX_WordBreakProp_LF,
- FX_WordBreakProp_NewLine,
- FX_WordBreakProp_Extend,
- FX_WordBreakProp_Format,
- FX_WordBreakProp_KataKana,
- FX_WordBreakProp_ALetter,
- FX_WordBreakProp_MidLetter,
- FX_WordBreakProp_MidNum,
- FX_WordBreakProp_MidNumLet,
- FX_WordBreakProp_Numberic,
- FX_WordBreakProp_ExtendNumLet,
-};
-FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint);
-
-#endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_
diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp
index 6af49d8021..bf2f3aeff7 100644
--- a/xfa/fwl/basewidget/fwl_comboboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp
@@ -6,8 +6,8 @@
#include "xfa/fwl/basewidget/fwl_comboboximp.h"
+#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fde/tto/fde_textout.h"
-#include "xfa/fee/fde_txtedtengine.h"
#include "xfa/fwl/basewidget/fwl_editimp.h"
#include "xfa/fwl/basewidget/fwl_formproxyimp.h"
#include "xfa/fwl/basewidget/fwl_listboximp.h"
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index 2d7d50580d..4e753b1f9f 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -10,10 +10,10 @@
#include <memory>
#include <vector>
+#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_render.h"
-#include "xfa/fee/fde_txtedtengine.h"
-#include "xfa/fee/ifde_txtedtpage.h"
+#include "xfa/fde/ifde_txtedtpage.h"
#include "xfa/fwl/basewidget/fwl_caretimp.h"
#include "xfa/fwl/basewidget/fwl_comboboximp.h"
#include "xfa/fwl/basewidget/fwl_scrollbarimp.h"
diff --git a/xfa/fwl/basewidget/fwl_editimp.h b/xfa/fwl/basewidget/fwl_editimp.h
index 484c1f8841..8f729f32e0 100644
--- a/xfa/fwl/basewidget/fwl_editimp.h
+++ b/xfa/fwl/basewidget/fwl_editimp.h
@@ -11,7 +11,8 @@
#include <memory>
#include <vector>
-#include "xfa/fee/ifde_txtedtengine.h"
+#include "xfa/fde/ifde_txtedtdorecord.h"
+#include "xfa/fde/ifde_txtedtengine.h"
#include "xfa/fwl/basewidget/ifwl_scrollbar.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fxgraphics/cfx_path.h"
@@ -23,7 +24,6 @@ class CFWL_MsgDeactivate;
class CFWL_MsgMouse;
class CFWL_WidgetImpDelegate;
class CFWL_WidgetImpProperties;
-class IFDE_TxtEdtDoRecord;
class IFWL_Caret;
class CFWL_EditImp : public CFWL_WidgetImp {