summaryrefslogtreecommitdiff
path: root/xfa/src/fee
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-02-25 17:20:30 -0500
committerDan Sinclair <dsinclair@chromium.org>2016-02-25 17:20:30 -0500
commit198362223d2257ded96895bd91df2bea422f361e (patch)
tree18f20dece89c011b527f2ff4d9440dc497e145ae /xfa/src/fee
parent9d8c29dbe9576a52b4f326fdce9d8ea669d26bff (diff)
downloadpdfium-198362223d2257ded96895bd91df2bea422f361e.tar.xz
Remove FDE_USEFORMATBLOCK.
This does not appear to ever be defined. There are a few methods which end up being empty after this change, removed those and their callers as well. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1736133002 .
Diffstat (limited to 'xfa/src/fee')
-rw-r--r--xfa/src/fee/include/ifde_txtedtengine.h11
-rw-r--r--xfa/src/fee/src/fee/fde_txtedtblock.cpp676
-rw-r--r--xfa/src/fee/src/fee/fde_txtedtblock.h239
-rw-r--r--xfa/src/fee/src/fee/fde_txtedtbuf.cpp38
-rw-r--r--xfa/src/fee/src/fee/fde_txtedtbuf.h8
-rw-r--r--xfa/src/fee/src/fee/fde_txtedtengine.cpp1098
-rw-r--r--xfa/src/fee/src/fee/fde_txtedtengine.h129
7 files changed, 7 insertions, 2192 deletions
diff --git a/xfa/src/fee/include/ifde_txtedtengine.h b/xfa/src/fee/include/ifde_txtedtengine.h
index bddad4c788..6773b50195 100644
--- a/xfa/src/fee/include/ifde_txtedtengine.h
+++ b/xfa/src/fee/include/ifde_txtedtengine.h
@@ -228,17 +228,6 @@ class IFDE_TxtEdtEngine {
const CFX_WideString& wsReplace) = 0;
virtual void SetLimit(int32_t nLimit) = 0;
virtual void SetAliasChar(FX_WCHAR wAlias) = 0;
- virtual void SetFormatBlock(int32_t nIndex,
- const CFX_WideString& wsBlockFormat) = 0;
- virtual int32_t CountEditBlocks() const = 0;
- virtual void GetEditBlockText(int32_t nIndex,
- CFX_WideString& wsBlockText) const = 0;
- virtual int32_t CountEditFields(int32_t nBlockIndex) const = 0;
- virtual void GetEditFieldText(int32_t nBlockIndex,
- int32_t nFieldIndex,
- CFX_WideString& wsFieldText) const = 0;
- virtual void StartEdit() = 0;
- virtual void EndEdit() = 0;
virtual void AddSelRange(int32_t nStart, int32_t nCount = -1) = 0;
virtual int32_t CountSelRanges() = 0;
virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart) = 0;
diff --git a/xfa/src/fee/src/fee/fde_txtedtblock.cpp b/xfa/src/fee/src/fee/fde_txtedtblock.cpp
deleted file mode 100644
index 9e61fcc969..0000000000
--- a/xfa/src/fee/src/fee/fde_txtedtblock.cpp
+++ /dev/null
@@ -1,676 +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/src/fee/src/fee/fde_txtedtblock.h"
-#include "xfa/src/foxitlib.h"
-#ifdef FDE_USEFORMATBLOCK
-#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9
-#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB
-#define FDE_TXTEDT_ZEROWIDTHSPACE 0x200B
-#define FDE_TXTEDT_ISINTEGER(a) ((a) >= L'0' && (a) <= L'9')
-#define FDE_TXTEDT_ISSIGN(a) (((a) == L'-') || ((a) == L'+'))
-CFDE_TxtEdtBlock::CFDE_TxtEdtBlock(CFDE_TxtEdtEngine* pEngine,
- const CFX_WideString& wsBlock,
- int32_t nPosition)
- : m_pEngine(pEngine),
- m_nDisplayLength(0),
- m_nIndex(0),
- m_nPosition(nPosition) {
- const FX_WCHAR* lpBuf = const FX_WCHAR * (wsBlock);
- int32_t nCount = wsBlock.GetLength();
- int32_t i = 0;
- CFX_WideString wsFix;
- int32_t j = 0;
- while (i < nCount) {
- if (lpBuf[i] != L'%') {
- wsFix += lpBuf[i];
- } else {
- i++;
- if (i < nCount) {
- if (lpBuf[i] == L'%') {
- wsFix += lpBuf[i];
- } else {
- if (!wsFix.IsEmpty()) {
- CFDE_TxtEdtField* pField = CFDE_TxtEdtField::Create(wsFix, j, this);
- j++;
- FXSYS_assert(pField);
- m_FieldArr.Add(pField);
- m_nDisplayLength += pField->GetDisplayLength();
- wsFix.Empty();
- }
- int32_t nPos = i - 1;
- while (lpBuf[i++] != L')') {
- continue;
- }
-
- i++;
- CFX_WideStringC wsField(lpBuf + nPos, i - nPos);
- CFDE_TxtEdtField* pField = CFDE_TxtEdtField::Create(wsField, j, this);
- j++;
- FXSYS_assert(pField);
- m_FieldArr.Add(pField);
- m_EditFieldArr.Add(pField);
- m_nDisplayLength += pField->GetDisplayLength();
- i--;
- }
- }
- }
- i++;
- }
- if (!wsFix.IsEmpty()) {
- CFDE_TxtEdtField* pField = CFDE_TxtEdtField::Create(wsFix, j, this);
- FXSYS_assert(pField);
- m_FieldArr.Add(pField);
- m_nDisplayLength += pField->GetDisplayLength();
- }
-}
-CFDE_TxtEdtBlock::~CFDE_TxtEdtBlock() {
- int32_t nCount = m_FieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- CFDE_TxtEdtField* pField = m_FieldArr[i];
- pField->Release();
- }
- m_FieldArr.RemoveAll();
-}
-void CFDE_TxtEdtBlock::GetDisplayText(CFX_WideString& wsDisplay) {
- int32_t nCount = m_FieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- CFDE_TxtEdtField* pField = m_FieldArr[i];
- CFX_WideString wsTemp;
- pField->GetDisplayText(wsTemp);
- wsDisplay += wsTemp;
- }
-}
-int32_t CFDE_TxtEdtBlock::GetLength() const {
- int32_t nDisplayLength = 0;
- int32_t nCount = m_FieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- CFDE_TxtEdtField* pField = m_FieldArr[i];
- nDisplayLength += pField->GetDisplayLength();
- }
- return nDisplayLength;
-}
-void CFDE_TxtEdtBlock::GetBlockText(CFX_WideString& wsBlock) {
- int32_t nCount = m_FieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- CFDE_TxtEdtField* pField = m_FieldArr[i];
- CFX_WideString wsTemp;
- pField->GetFieldText(wsTemp);
- wsBlock += wsTemp;
- }
-}
-int32_t CFDE_TxtEdtBlock::CountField() const {
- return m_EditFieldArr.GetSize();
-}
-void CFDE_TxtEdtBlock::GetFieldText(int32_t nIndex, CFX_WideString& wsField) {
- CFDE_TxtEdtField* pField = m_EditFieldArr[nIndex];
- pField->GetFieldText(wsField);
-}
-int32_t CFDE_TxtEdtBlock::GetFieldTextLength() const {
- int32_t nTotalLength = 0;
- int32_t nCount = m_EditFieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- CFDE_TxtEdtField* pField = m_EditFieldArr[i];
- nTotalLength = pField->GetFieldTextLength();
- }
- return nTotalLength;
-}
-int32_t CFDE_TxtEdtBlock::GetPos() const {
- return m_nPosition;
-}
-void CFDE_TxtEdtBlock::GetRealText(CFX_WideString& wsText) const {
- int32_t nCount = m_FieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- CFDE_TxtEdtField* pField = m_FieldArr[i];
- CFX_WideString wsTemp;
- pField->GetFieldText(wsTemp);
- wsText += wsTemp;
- }
-}
-void CFDE_TxtEdtBlock::Backup() {
- int32_t nCount = m_EditFieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- m_EditFieldArr[i]->Backup();
- }
-}
-void CFDE_TxtEdtBlock::Restore() {
- int32_t nCount = m_EditFieldArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- m_EditFieldArr[i]->Restore();
- }
-}
-CFDE_TxtEdtFieldFormatParser::CFDE_TxtEdtFieldFormatParser() {}
-CFDE_TxtEdtFieldFormatParser::~CFDE_TxtEdtFieldFormatParser() {
- FDE_LPTXTEDTFORMATITEM lpItem = NULL;
- int32_t nCount = m_ItemArr.GetSize();
- for (int32_t i = 0; i < nCount; i++) {
- lpItem = m_ItemArr[i];
- delete lpItem;
- }
- m_ItemArr.RemoveAll();
-}
-FX_BOOL CFDE_TxtEdtFieldFormatParser::Parse(const CFX_WideString& wsFormat) {
- m_wsFormat = wsFormat;
- const FX_WCHAR* pBuf = const FX_WCHAR * (m_wsFormat);
- int32_t nCount = m_wsFormat.GetLength();
- nCount -= 2;
- int32_t i = 0;
- for (; i < nCount; i++) {
- FX_WCHAR wChar = pBuf[i];
- if (wChar == L'(') {
- break;
- }
- }
- i++;
- FDE_TXTEDTFORMATITEM FormatItem;
- for (; i < nCount; i++) {
- while (pBuf[i] == L' ') {
- i++;
- }
- FormatItem.nKeyStart = i;
- while (pBuf[i] != L':') {
- i++;
- }
- FormatItem.nKeyCount = i - FormatItem.nKeyStart;
- i++;
- FormatItem.nValStart = i;
- while (pBuf[i] != L';' && i < nCount) {
- i++;
- }
- FormatItem.nValCount = i - FormatItem.nValStart;
- FDE_LPTXTEDTFORMATITEM pFormatItem = new FDE_TXTEDTFORMATITEM;
- FXSYS_memcpy(pFormatItem, &FormatItem, sizeof(FDE_TXTEDTFORMATITEM));
- m_ItemArr.Add(pFormatItem);
- }
- return TRUE;
-}
-int32_t CFDE_TxtEdtFieldFormatParser::CountItems() const {
- return m_ItemArr.GetSize();
-}
-void CFDE_TxtEdtFieldFormatParser::GetItem(int32_t nIndex,
- CFX_WideString& wsKey,
- CFX_WideString& wsValue) const {
- FDE_LPTXTEDTFORMATITEM lpItem = m_ItemArr[nIndex];
- const FX_WCHAR* lpSrcBuf = const FX_WCHAR * (m_wsFormat);
- FX_WCHAR* lpDstBuf = wsKey.GetBuffer(lpItem->nKeyCount);
- FXSYS_memcpy(lpDstBuf, lpSrcBuf + lpItem->nKeyStart,
- lpItem->nKeyCount * sizeof(FX_WCHAR));
- wsKey.ReleaseBuffer(lpItem->nKeyCount);
- lpDstBuf = wsValue.GetBuffer(lpItem->nValCount);
- FXSYS_memcpy(lpDstBuf, lpSrcBuf + lpItem->nValStart,
- lpItem->nValCount * sizeof(FX_WCHAR));
- wsValue.ReleaseBuffer(lpItem->nValCount);
-}
-CFDE_TxtEdtField* CFDE_TxtEdtField::Create(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock) {
- if (wsField[0] != L'%' || (wsField[0] == L'%' && wsField[1] == L'%')) {
- return new CFDE_TxtEdtField_Fixed(wsField, nIndex, pBlock);
- }
- FX_WCHAR wcType = wsField[wsField.GetLength() - 1];
- switch (wcType) {
- case L'd':
- return new CFDE_TxtEdtField_Integer(wsField, nIndex, pBlock);
- case L'f':
- return new CFDE_TxtEdtField_Float(wsField, nIndex, pBlock);
- case L's':
- return new CFDE_TxtEdtField_String(wsField, nIndex, pBlock);
- case L'p':
- return new CFDE_TxtEdtField_Password(wsField, nIndex, pBlock);
- default:
- break;
- }
- return NULL;
-}
-void CFDE_TxtEdtField::Release() {
- delete this;
-}
-CFDE_TxtEdtField::CFDE_TxtEdtField(int32_t nIndex, CFDE_TxtEdtBlock* pBlock)
- : m_nLength(-1),
- m_wcFill(L' '),
- m_bReserveSpace(FALSE),
- m_bLeftAlignment(TRUE),
- m_nIndex(nIndex),
- m_pBlock(pBlock) {
- FXSYS_assert(pBlock);
-}
-int32_t CFDE_TxtEdtField::Insert(int32_t nIndex,
- const CFX_WideString& wsIns,
- int32_t& nCaret,
- FX_BOOL& bBefore) {
- int32_t nFieldLength = m_wsField.GetLength();
- int32_t nInnerIndex = nIndex - FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- if (m_bReserveSpace && !m_bLeftAlignment) {
- nInnerIndex -= (m_nLength - nFieldLength);
- }
- FXSYS_assert(nInnerIndex >= 0 && nInnerIndex <= nFieldLength);
- CFX_WideString wsTemp = m_wsField;
- int32_t nInsLength = wsIns.GetLength();
- for (int32_t i = 0; i < nInsLength; i++, nInnerIndex++) {
- wsTemp.Insert(nInnerIndex, wsIns[i]);
- }
- int32_t nRet = Validate(wsTemp);
- switch (nRet) {
- case FDE_FORMAT_FIELD_VALIDATE_F_FULL:
- return FDE_FORMAT_FIELD_INSERT_RET_F_FULL;
- case FDE_FORMAT_FIELD_VALIDATE_F_INVALIDATE:
- return FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE;
- case FDE_FORMAT_FIELD_VALIDATE_S:
- default:
- break;
- }
- m_wsField = wsTemp;
- nCaret = nIndex +
- ((m_bReserveSpace && !m_bLeftAlignment) ? -nInsLength : nInsLength);
- bBefore = TRUE;
- return (nFieldLength + nInsLength < m_nLength)
- ? FDE_FORMAT_FIELD_INSERT_RET_S_NORMAL
- : FDE_FORMAT_FIELD_INSERT_RET_S_FULL;
-}
-int32_t CFDE_TxtEdtField::Delete(int32_t nIndex,
- int32_t nCount,
- CFX_WideString& wsDel,
- int32_t& nCaret,
- FX_BOOL& bBefore) {
- int32_t nFieldLength = m_wsField.GetLength();
- int32_t nInnerIndex = nIndex - FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- if (m_bReserveSpace && !m_bLeftAlignment) {
- nInnerIndex -= (m_nLength - nFieldLength);
- }
- if (nInnerIndex < 0 || (nInnerIndex + nCount) > nFieldLength) {
- return FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY;
- }
- CFX_WideString wsTemp = m_wsField;
- wsTemp.Delete(nInnerIndex, nCount);
- int32_t nRet = Validate(wsTemp);
- switch (nRet) {
- case FDE_FORMAT_FIELD_VALIDATE_F_FULL:
- return FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY;
- case FDE_FORMAT_FIELD_VALIDATE_F_INVALIDATE:
- return FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE;
- case FDE_FORMAT_FIELD_VALIDATE_S:
- default:
- break;
- }
- FX_WCHAR* lpBuf = wsDel.GetBuffer(nCount);
- FXSYS_memcpy(lpBuf, const FX_WCHAR*(m_wsField) + nInnerIndex,
- nCount * sizeof(FX_WCHAR));
- wsDel.ReleaseBuffer(nCount);
- m_wsField = wsTemp;
- nCaret = nIndex + (m_bReserveSpace && !m_bLeftAlignment) ? nCount : 0;
- bBefore = TRUE;
- return FDE_FORMAT_FIELD_DELETE_RET_S;
-}
-int32_t CFDE_TxtEdtField::Replace(int32_t nIndex,
- int32_t nCount,
- const CFX_WideString& wsIns,
- CFX_WideString& wsDel,
- int32_t& nCaret,
- FX_BOOL& bBefore) {
- int32_t nInnerIndex = nIndex - FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- int32_t nInsLength = wsIns.GetLength();
- int32_t nFieldLength = m_wsField.GetLength();
- CFX_WideString wsTemp = m_wsField;
- if (m_bReserveSpace && !m_bLeftAlignment) {
- nInnerIndex -= (m_nLength - nFieldLength);
- }
- FXSYS_assert(nInnerIndex >= 0 && nInnerIndex <= nFieldLength);
- if (nInnerIndex + nCount > nFieldLength) {
- return FALSE;
- }
- wsTemp.Delete(nInnerIndex, nCount);
- int32_t nInnerIndexBK = nInnerIndex;
- for (int32_t i = 0; i < nInsLength; i++, nInnerIndex++) {
- wsTemp.Insert(nInnerIndex, wsIns[i]);
- }
- int32_t nRet = Validate(wsTemp);
- switch (nRet) {
- case FDE_FORMAT_FIELD_VALIDATE_F_FULL:
- return FDE_FORMAT_FIELD_INSERT_RET_F_FULL;
- case FDE_FORMAT_FIELD_VALIDATE_F_INVALIDATE:
- return FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE;
- default:
- break;
- }
- FX_WCHAR* lpBuffer = wsDel.GetBuffer(nCount);
- const FX_WCHAR* lpSrcBuf = const FX_WCHAR * (m_wsField);
- FXSYS_memcpy(lpBuffer, lpSrcBuf + nInnerIndexBK, nCount * sizeof(FX_WCHAR));
- wsDel.ReleaseBuffer(nCount);
- m_wsField = wsTemp;
- nCaret =
- nIndex + ((m_bReserveSpace && !m_bLeftAlignment) ? (nCount - nInsLength)
- : (nInsLength));
- return FDE_FORMAT_FIELD_INSERT_RET_S_NORMAL;
-}
-void CFDE_TxtEdtField::GetDisplayText(CFX_WideString& wsDisplay) {
- CFX_WideString wsField;
- GetNormalizedFieldText(wsField);
- int32_t nLength = wsField.GetLength() + FDE_FORMAT_EDIT_FIELD_HADERSIZE +
- FDE_FORMAT_EDIT_FIELD_TAILSIZE;
- FX_WCHAR* lpBuffer = wsDisplay.GetBuffer(nLength);
- lpBuffer[0] = FDE_TXTEDT_FORMATBLOCK_BGN;
- lpBuffer[nLength - 1] = FDE_TXTEDT_FORMATBLOCK_END;
- FX_DWORD nAddress = (FX_DWORD) this;
- FXSYS_memcpy(lpBuffer + 1, &nAddress, sizeof(FX_DWORD));
- FXSYS_memcpy(lpBuffer + 3, const FX_WCHAR*(wsField),
- (nLength - 4) * sizeof(FX_WCHAR));
- wsDisplay.ReleaseBuffer(nLength);
-}
-int32_t CFDE_TxtEdtField::GetDisplayLength() {
- return (m_bReserveSpace ? m_nLength : m_wsField.GetLength()) +
- FDE_FORMAT_EDIT_FIELD_HADERSIZE + FDE_FORMAT_EDIT_FIELD_TAILSIZE;
-}
-void CFDE_TxtEdtField::GetFieldText(CFX_WideString& wsField) {
- wsField = m_wsField;
-}
-int32_t CFDE_TxtEdtField::GetFieldTextLength() const {
- return m_wsField.GetLength();
-}
-int32_t CFDE_TxtEdtField::GetRealIndex(int32_t nIndex) const {
- int32_t nInnerIndex = nIndex - FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- if (nInnerIndex < 0) {
- return 0;
- }
- int32_t nFieldLength = m_wsField.GetLength();
- if (m_bReserveSpace && !m_bLeftAlignment) {
- nInnerIndex -= (m_nLength - nFieldLength);
- }
- if (nInnerIndex < 0) {
- return 0;
- }
- if (nInnerIndex >= nFieldLength) {
- return nFieldLength;
- }
- return nInnerIndex + 1;
-}
-int32_t CFDE_TxtEdtField::NormalizeCaretPos(
- int32_t nIndex,
- FDE_FORMAT_CARET_DIRECTION eDirection) const {
- nIndex -= FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- int32_t nLength = m_wsField.GetLength();
- if (m_bReserveSpace) {
- int32_t nFieldLength = m_wsField.GetLength();
- if (m_bLeftAlignment) {
- if (nIndex > nFieldLength) {
- if (eDirection == FDE_FORMAT_CARET_FORWARD) {
- return -1;
- }
- nIndex = nFieldLength;
- }
- } else {
- int32_t nReserveLength = m_nLength - nFieldLength;
- if (nIndex < nReserveLength) {
- if (eDirection == FDE_FORMAT_CARET_BACKWARD) {
- return -2;
- }
- nIndex = nReserveLength;
- }
- }
- }
- return nIndex + FDE_FORMAT_EDIT_FIELD_HADERSIZE;
-}
-FX_BOOL CFDE_TxtEdtField::GetEditableRange(int32_t& nBgn, int32_t& nEnd) const {
- if (m_bReserveSpace && !m_bLeftAlignment) {
- nEnd = FDE_FORMAT_EDIT_FIELD_HADERSIZE + m_nLength;
- nBgn = nEnd - m_wsField.GetLength();
- } else {
- nBgn = FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- nEnd = nBgn + m_wsField.GetLength();
- }
- return TRUE;
-}
-void CFDE_TxtEdtField::Backup() {
- m_wsBackup = m_wsField;
-}
-void CFDE_TxtEdtField::Restore() {
- m_wsField = m_wsBackup;
-}
-int32_t CFDE_TxtEdtField::Validate(const CFX_WideString& wsText) const {
- if (m_nLength < 0) {
- return FDE_FORMAT_FIELD_DELETE_RET_S;
- }
- return wsText.GetLength() <= m_nLength ? FDE_FORMAT_FIELD_VALIDATE_S
- : FDE_FORMAT_FIELD_VALIDATE_F_FULL;
-}
-void CFDE_TxtEdtField::GetNormalizedFieldText(CFX_WideString& wsField) const {
- wsField = m_wsField;
- if (m_nLength == -1) {
- return;
- }
- if (m_bReserveSpace) {
- int32_t nField = wsField.GetLength();
- int32_t nFill = m_nLength - nField;
- if (m_bLeftAlignment) {
- while (nFill--) {
- wsField.Insert(nField++, m_wcFill);
- }
- } else {
- while (nFill--) {
- wsField.Insert(0, m_wcFill);
- }
- }
- }
-}
-CFDE_TxtEdtField_Integer::CFDE_TxtEdtField_Integer(
- const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock)
- : m_bSign(FALSE), CFDE_TxtEdtField(nIndex, pBlock) {
- CFDE_TxtEdtFieldFormatParser FormatParser;
- FormatParser.Parse(wsField);
- int32_t nCount = FormatParser.CountItems();
- CFX_WideString wskey;
- CFX_WideString wsVal;
- for (int32_t i = 0; i < nCount; i++) {
- FormatParser.GetItem(i, wskey, wsVal);
- if (wskey.Equal(L"Length")) {
- m_nLength = wsVal.GetInteger();
- } else if (wskey.Equal(L"Sign")) {
- m_bSign = wsVal.GetInteger() != 0;
- } else if (wskey.Equal(L"FillChar")) {
- m_wcFill = wsVal[0];
- } else {
- FXSYS_assert(0);
- }
- wskey.Empty();
- wsVal.Empty();
- }
- if (m_nLength == -1) {
- m_bReserveSpace = FALSE;
- }
-}
-int32_t CFDE_TxtEdtField_Integer::Validate(const CFX_WideString& wsText) const {
- int32_t i = 0;
- if (m_bSign) {
- FX_WCHAR wcTemp = wsText[0];
- if (FDE_TXTEDT_ISSIGN(wcTemp)) {
- i++;
- }
- }
- int32_t nLength = wsText.GetLength();
- if (m_nLength > 0) {
- if (nLength - i > (m_nLength - (m_bSign ? 1 : 0))) {
- return FDE_FORMAT_FIELD_VALIDATE_F_FULL;
- }
- }
- for (; i < nLength; i++) {
- FX_WCHAR wcTemp = wsText[i];
- if (!FDE_TXTEDT_ISINTEGER(wcTemp)) {
- return FDE_FORMAT_FIELD_VALIDATE_F_INVALIDATE;
- }
- }
- return FDE_FORMAT_FIELD_VALIDATE_S;
-}
-CFDE_TxtEdtField_Float::CFDE_TxtEdtField_Float(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock)
- : CFDE_TxtEdtField(nIndex, pBlock),
- m_bSigned(FALSE),
- m_nIntPartlength(-1),
- m_nDecPartLength(-1) {
- CFDE_TxtEdtFieldFormatParser FormatParser;
- FormatParser.Parse(wsField);
- int32_t nCount = FormatParser.CountItems();
- CFX_WideString wskey;
- CFX_WideString wsVal;
- for (int32_t i = 0; i < nCount; i++) {
- FormatParser.GetItem(i, wskey, wsVal);
- if (wskey.Equal(L"DecLength")) {
- m_nDecPartLength = wsVal.GetInteger();
- } else if (wskey.Equal(L"IntLength")) {
- m_nIntPartlength = wsVal.GetInteger();
- } else if (wskey.Equal(L"Sign")) {
- m_bSigned = wsVal.GetInteger() != 0;
- } else if (wskey.Equal(L"FillChar")) {
- m_wcFill = wsVal[0];
- } else {
- FXSYS_assert(0);
- }
- if (m_nIntPartlength == -1 || m_nDecPartLength == -1) {
- m_nLength = -1;
- } else {
- m_nLength = m_nIntPartlength + m_nDecPartLength + 1 + (m_bSigned ? 1 : 0);
- }
- m_bReserveSpace = TRUE;
- wskey.Empty();
- wsVal.Empty();
- }
-}
-int32_t CFDE_TxtEdtField_Float::Validate(const CFX_WideString& wsText) const {
- int32_t nLength = wsText.GetLength();
- if (m_nLength != -1 && (nLength > m_nLength)) {
- return FDE_FORMAT_FIELD_VALIDATE_F_FULL;
- }
- const FX_WCHAR* lpBuf = const FX_WCHAR * (wsText);
- int32_t i = 0;
- if (m_bSigned) {
- FX_WCHAR wcTemp = lpBuf[0];
- if (FDE_TXTEDT_ISSIGN(wcTemp)) {
- i++;
- }
- }
- int32_t nIntPart = 0;
- int32_t nPoint = 0;
- for (; i < nLength; i++) {
- FX_WCHAR wcTemp = lpBuf[i];
- if (!FDE_TXTEDT_ISINTEGER(wcTemp)) {
- if (wcTemp != L'.') {
- return FDE_FORMAT_FIELD_VALIDATE_F_INVALIDATE;
- }
- nPoint = 1;
- break;
- }
- nIntPart++;
- }
- if (m_nIntPartlength != -1 && (nIntPart > m_nIntPartlength)) {
- return FDE_FORMAT_FIELD_VALIDATE_F_FULL;
- }
- if (m_nDecPartLength != -1 &&
- (nLength - nIntPart - nPoint > m_nDecPartLength)) {
- return FDE_FORMAT_FIELD_VALIDATE_F_FULL;
- }
- i++;
- for (; i < nLength; i++) {
- FX_WCHAR wcTemp = lpBuf[i];
- if (!FDE_TXTEDT_ISINTEGER(wcTemp)) {
- return FDE_FORMAT_FIELD_VALIDATE_F_FULL;
- }
- }
- return FDE_FORMAT_FIELD_VALIDATE_S;
-}
-CFDE_TxtEdtField_Password::CFDE_TxtEdtField_Password(
- const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock)
- : CFDE_TxtEdtField(nIndex, pBlock), m_wcAlias(L'*') {
- CFDE_TxtEdtFieldFormatParser FormatParser;
- FormatParser.Parse(wsField);
- int32_t nCount = FormatParser.CountItems();
- CFX_WideString wskey;
- CFX_WideString wsVal;
- for (int32_t i = 0; i < nCount; i++) {
- FormatParser.GetItem(i, wskey, wsVal);
- if (wskey.Equal(L"Length")) {
- m_nLength = wsVal.GetInteger();
- } else if (wskey.Equal(L"AliasChar")) {
- m_wcAlias = wsVal[0];
- } else {
- FXSYS_assert(0);
- }
- wskey.Empty();
- wsVal.Empty();
- }
- if (m_nLength == -1) {
- m_bReserveSpace = FALSE;
- }
-}
-void CFDE_TxtEdtField_Password::GetNormalizedFieldText(
- CFX_WideString& wsField) const {
- int32_t nFiledLength = m_wsField.GetLength();
- int32_t nLength = m_bReserveSpace ? m_nLength : nFiledLength;
- FX_WCHAR* lpBuf = wsField.GetBuffer(nLength);
- int32_t nSpaceLength = nLength - nFiledLength;
- int32_t nFirstPart = m_bLeftAlignment ? nFiledLength : nSpaceLength;
- FX_WCHAR wFirstChar = m_bLeftAlignment ? m_wcAlias : L' ';
- FX_WCHAR wSecondChar = m_bLeftAlignment ? L' ' : m_wcAlias;
- int32_t i = 0;
- for (; i < nFirstPart; i++) {
- lpBuf[i] = wFirstChar;
- }
- for (; i < nLength; i++) {
- lpBuf[i] = wSecondChar;
- }
- wsField.ReleaseBuffer(nLength);
-}
-CFDE_TxtEdtField_String::CFDE_TxtEdtField_String(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock)
- : CFDE_TxtEdtField(nIndex, pBlock) {
- CFDE_TxtEdtFieldFormatParser FormatParser;
- FormatParser.Parse(wsField);
- int32_t nCount = FormatParser.CountItems();
- CFX_WideString wskey;
- CFX_WideString wsVal;
- for (int32_t i = 0; i < nCount; i++) {
- FormatParser.GetItem(i, wskey, wsVal);
- if (wskey.Equal(L"Length")) {
- m_nLength = wsVal.GetInteger();
- } else {
- FXSYS_assert(0);
- }
- wskey.Empty();
- wsVal.Empty();
- }
-}
-CFDE_TxtEdtField_Fixed::CFDE_TxtEdtField_Fixed(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock)
- : CFDE_TxtEdtField(nIndex, pBlock) {
- m_wsField = wsField;
- m_nLength = wsField.GetLength();
-}
-void CFDE_TxtEdtField_Fixed::GetDisplayText(CFX_WideString& wsDisplay) {
- int32_t nLength = m_wsField.GetLength() + FDE_FORMAT_EDIT_FIELD_HADERSIZE +
- FDE_FORMAT_EDIT_FIELD_TAILSIZE;
- FX_WCHAR* lpBuffer = wsDisplay.GetBuffer(nLength);
- lpBuffer[0] = FDE_TXTEDT_FORMATBLOCK_BGN;
- lpBuffer[nLength - 1] = FDE_TXTEDT_FORMATBLOCK_END;
- FX_DWORD nAddress = (FX_DWORD) this;
- FXSYS_memcpy(lpBuffer + 1, &nAddress, sizeof(FX_DWORD));
- FXSYS_memcpy(lpBuffer + 3, const FX_WCHAR*(m_wsField),
- (nLength - 4) * sizeof(FX_WCHAR));
- wsDisplay.ReleaseBuffer(nLength);
-}
-int32_t CFDE_TxtEdtField_Fixed::NormalizeCaretPos(
- int32_t nIndex,
- FDE_FORMAT_CARET_DIRECTION eDirection) const {
- FXSYS_assert(nIndex >= 0 && nIndex <= m_nLength);
- if (eDirection == FDE_FORMAT_CARET_MIDDLE) {
- return (nIndex > m_wsField.GetLength() / 2) ? -1 : -2;
- }
- return eDirection == FDE_FORMAT_CARET_BACKWARD ? -2 : -1;
-}
-#endif
diff --git a/xfa/src/fee/src/fee/fde_txtedtblock.h b/xfa/src/fee/src/fee/fde_txtedtblock.h
deleted file mode 100644
index 60261d0a89..0000000000
--- a/xfa/src/fee/src/fee/fde_txtedtblock.h
+++ /dev/null
@@ -1,239 +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_SRC_FEE_SRC_FEE_FDE_TXTEDTBLOCK_H_
-#define XFA_SRC_FEE_SRC_FEE_FDE_TXTEDTBLOCK_H_
-
-#ifdef FDE_USEFORMATBLOCK
-class CFDE_TxtEdtEngine;
-class CFDE_TxtEdtBlock;
-class CFDE_TxtEdtFieldFormatParser;
-class CFDE_TxtEdtField;
-class CFDE_TxtEdtField_Integer;
-class CFDE_TxtEdtField_Float;
-class CFDE_TxtEdtField_Password;
-class CFDE_TxtEdtField_String;
-class CFDE_TxtEdtField_Fixed;
-#define FDE_FORMAT_EDIT_FIELD_HADERSIZE 3
-#define FDE_FORMAT_EDIT_FIELD_TAILSIZE 1
-enum FDE_FORMAT_FIELD_INSERT_RET {
- FDE_FORMAT_FIELD_INSERT_RET_S_NORMAL = 0,
- FDE_FORMAT_FIELD_INSERT_RET_S_FULL,
- FDE_FORMAT_FIELD_INSERT_RET_F_FULL,
- FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE,
-};
-enum FDE_FORMAT_FIELD_DELETE_RET {
- FDE_FORMAT_FIELD_DELETE_RET_S = 0,
- FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE,
- FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY,
-};
-enum FDE_FORMAT_FIELD_VALIDATE_RET {
- FDE_FORMAT_FIELD_VALIDATE_S = 0,
- FDE_FORMAT_FIELD_VALIDATE_F_FULL,
- FDE_FORMAT_FIELD_VALIDATE_F_INVALIDATE,
-};
-enum FDE_FORMAT_CARET_DIRECTION {
- FDE_FORMAT_CARET_FORWARD,
- FDE_FORMAT_CARET_MIDDLE,
- FDE_FORMAT_CARET_BACKWARD
-};
-class CFDE_TxtEdtBlock {
- public:
- CFDE_TxtEdtBlock(CFDE_TxtEdtEngine* pEngine,
- const CFX_WideString& wsBlock,
- int32_t nPosition);
- ~CFDE_TxtEdtBlock();
- void GetDisplayText(CFX_WideString& wsDisplay);
- int32_t GetLength() const;
- void GetBlockText(CFX_WideString& wsBlock);
- int32_t CountField() const;
- void GetFieldText(int32_t nIndex, CFX_WideString& wsField);
- int32_t GetFieldTextLength() const;
-
- int32_t GetPos() const;
- void GetRealText(CFX_WideString& wsText) const;
- void Backup();
- void Restore();
- void SetIndex(int32_t nIndex) { m_nIndex = nIndex; }
- int32_t GetIndex() const { return m_nIndex; }
-
- private:
- CFDE_TxtEdtEngine* m_pEngine;
- int32_t m_nDisplayLength;
- int32_t m_nIndex;
-
- int32_t m_nPosition;
- CFX_ArrayTemplate<CFDE_TxtEdtField*> m_FieldArr;
- CFX_ArrayTemplate<CFDE_TxtEdtField*> m_EditFieldArr;
-};
-class CFDE_TxtEdtFieldFormatParser {
- public:
- CFDE_TxtEdtFieldFormatParser();
- ~CFDE_TxtEdtFieldFormatParser();
- FX_BOOL Parse(const CFX_WideString& wsFormat);
- int32_t CountItems() const;
- void GetItem(int32_t nIndex,
- CFX_WideString& wsKey,
- CFX_WideString& wsValue) const;
-
- private:
- typedef struct {
- int32_t nKeyStart;
- int32_t nKeyCount;
- int32_t nValStart;
- int32_t nValCount;
- } FDE_TXTEDTFORMATITEM, *FDE_LPTXTEDTFORMATITEM;
-
- CFX_WideString m_wsFormat;
- CFX_ArrayTemplate<FDE_LPTXTEDTFORMATITEM> m_ItemArr;
-};
-class CFDE_TxtEdtField {
- public:
- static CFDE_TxtEdtField* Create(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock);
- virtual void Release();
- virtual int32_t Insert(int32_t nIndex,
- const CFX_WideString& wsIns,
- int32_t& nCaret,
- FX_BOOL& bBefore);
- virtual int32_t Delete(int32_t nIndex,
- int32_t nCount,
- CFX_WideString& wsDel,
- int32_t& nCaret,
- FX_BOOL& bBefore);
- virtual int32_t Replace(int32_t nIndex,
- int32_t nCount,
- const CFX_WideString& wsIns,
- CFX_WideString& wsDel,
- int32_t& nCaret,
- FX_BOOL& bBefore);
- virtual void GetDisplayText(CFX_WideString& wsDisplay);
- virtual int32_t GetDisplayLength();
- virtual void GetFieldText(CFX_WideString& wsField);
- virtual int32_t GetFieldTextLength() const;
- virtual int32_t GetRealIndex(int32_t nIndex) const;
-
- virtual int32_t NormalizeCaretPos(
- int32_t nIndex,
- FDE_FORMAT_CARET_DIRECTION eDirection = FDE_FORMAT_CARET_MIDDLE) const;
-
- virtual FX_BOOL GetEditableRange(int32_t& nBgn, int32_t& nEnd) const;
- virtual void Backup();
- virtual void Restore();
- virtual FX_BOOL IsFix() const { return FALSE; }
- void SetIndex(int32_t nIndex) { m_nIndex = nIndex; }
- int32_t GetIndex() const { return m_nIndex; }
- int32_t GetBlockIndex() const { return m_pBlock->GetIndex(); }
-
- protected:
- CFDE_TxtEdtField(int32_t nIndex, CFDE_TxtEdtBlock* pBlock);
- virtual ~CFDE_TxtEdtField() {}
- virtual int32_t Validate(const CFX_WideString& wsText) const;
- virtual void GetNormalizedFieldText(CFX_WideString& wsField) const;
- int32_t m_nLength;
- CFX_WideString m_wsField;
- CFX_WideString m_wsBackup;
- FX_WCHAR m_wcFill;
- FX_BOOL m_bReserveSpace;
- FX_BOOL m_bLeftAlignment;
- int32_t m_nIndex;
- CFDE_TxtEdtBlock* m_pBlock;
-};
-class CFDE_TxtEdtField_Integer : public CFDE_TxtEdtField {
- public:
- CFDE_TxtEdtField_Integer(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock);
-
- protected:
- virtual ~CFDE_TxtEdtField_Integer() {}
- virtual int32_t Validate(const CFX_WideString& wsText) const;
-
- private:
- FX_BOOL m_bSign;
-};
-class CFDE_TxtEdtField_Float : public CFDE_TxtEdtField {
- public:
- CFDE_TxtEdtField_Float(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock);
-
- protected:
- virtual ~CFDE_TxtEdtField_Float() {}
- virtual int32_t Validate(const CFX_WideString& wsText) const;
-
- private:
- FX_BOOL m_bSigned;
- int32_t m_nIntPartlength;
- int32_t m_nDecPartLength;
-};
-class CFDE_TxtEdtField_Password : public CFDE_TxtEdtField {
- public:
- CFDE_TxtEdtField_Password(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock);
-
- protected:
- virtual ~CFDE_TxtEdtField_Password() {}
- virtual void GetNormalizedFieldText(CFX_WideString& wsField) const;
-
- private:
- FX_WCHAR m_wcAlias;
-};
-class CFDE_TxtEdtField_String : public CFDE_TxtEdtField {
- public:
- CFDE_TxtEdtField_String(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock);
-
- protected:
- virtual ~CFDE_TxtEdtField_String() {}
-};
-class CFDE_TxtEdtField_Fixed : public CFDE_TxtEdtField {
- public:
- CFDE_TxtEdtField_Fixed(const CFX_WideString& wsField,
- int32_t nIndex,
- CFDE_TxtEdtBlock* pBlock);
- virtual int32_t Insert(int32_t nIndex,
- const CFX_WideString& wsIns,
- int32_t& nCaret,
- FX_BOOL& bBefore) {
- return FALSE;
- }
- virtual int32_t Delete(int32_t nIndex,
- int32_t nCount,
- CFX_WideString& wsDel,
- int32_t& nCaret,
- FX_BOOL& bBefore) {
- return FALSE;
- }
- virtual int32_t Replace(int32_t nIndex,
- int32_t nCount,
- const CFX_WideString& wsIns,
- CFX_WideString& wsDel,
- int32_t& nCaret,
- FX_BOOL& bBefore) {
- return FALSE;
- }
- virtual void GetDisplayText(CFX_WideString& wsDisplay);
- virtual int32_t NormalizeCaretPos(
- int32_t nIndex,
- FDE_FORMAT_CARET_DIRECTION eDirection) const;
- virtual FX_BOOL GetEditableRange(int32_t& nBgn, int32_t& nEnd) const {
- return FALSE;
- }
- virtual void Backup() {}
- virtual void Restore() {}
-
- virtual FX_BOOL IsFix() const { return TRUE; }
-
- protected:
- virtual ~CFDE_TxtEdtField_Fixed() {}
-};
-#endif
-
-#endif // XFA_SRC_FEE_SRC_FEE_FDE_TXTEDTBLOCK_H_
diff --git a/xfa/src/fee/src/fee/fde_txtedtbuf.cpp b/xfa/src/fee/src/fee/fde_txtedtbuf.cpp
index 7b71f47bdc..b05a691c1d 100644
--- a/xfa/src/fee/src/fee/fde_txtedtbuf.cpp
+++ b/xfa/src/fee/src/fee/fde_txtedtbuf.cpp
@@ -14,20 +14,12 @@
#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9
#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB
#define FDE_TXTEDT_ZEROWIDTHSPACE 0x200B
-#ifdef FDE_USEFORMATBLOCK
-CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf,
- FX_BOOL bForDisplay)
-#else
+
CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias)
-#endif
: m_pBuf(pBuf),
m_nCurChunk(0),
m_nCurIndex(0),
m_nIndex(0),
-#ifdef FDE_USEFORMATBLOCK
- m_bForDisplay(bForDisplay),
- m_nAliasCount(0),
-#endif
m_Alias(wcAlias) {
FXSYS_assert(m_pBuf);
}
@@ -96,34 +88,6 @@ int32_t CFDE_TxtEdtBufIter::GetAt() const {
}
FX_WCHAR CFDE_TxtEdtBufIter::GetChar() {
FXSYS_assert(m_nIndex >= 0 && m_nIndex < m_pBuf->m_nTotal);
-#ifdef FDE_USEFORMATBLOCK
- if (m_bForDisplay) {
- if (m_bInField) {
- FXSYS_assert(m_nAliasCount >= 0 && m_nAliasCount <= 2);
- if (m_nAliasCount > 0) {
- m_nAliasCount--;
- return FDE_TXTEDT_ZEROWIDTHSPACE;
- }
- FX_WCHAR wc =
- ((CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk])
- ->wChars[m_nCurIndex];
- if (wc == FDE_TXTEDT_FORMATBLOCK_END) {
- m_nAliasCount = 0;
- m_bInField = FALSE;
- }
- return wc;
- } else {
- FX_WCHAR wc =
- ((CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk])
- ->wChars[m_nCurIndex];
- if (wc == FDE_TXTEDT_FORMATBLOCK_BGN) {
- m_nAliasCount = 2;
- m_bInField = TRUE;
- }
- return wc;
- }
- }
-#endif
if (m_Alias == 0 || m_nIndex == (m_pBuf->m_nTotal - 1)) {
return ((CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk])
->wChars[m_nCurIndex];
diff --git a/xfa/src/fee/src/fee/fde_txtedtbuf.h b/xfa/src/fee/src/fee/fde_txtedtbuf.h
index be4e942d9b..c9f5fc40e1 100644
--- a/xfa/src/fee/src/fee/fde_txtedtbuf.h
+++ b/xfa/src/fee/src/fee/fde_txtedtbuf.h
@@ -14,11 +14,7 @@ class CFDE_TxtEdtBuf;
class CFDE_TxtEdtBufIter : public IFX_CharIter {
public:
-#ifdef FDE_USEFORMATBLOCK
- CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_BOOL bForDisplay = TRUE);
-#else
CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias = 0);
-#endif
virtual void Release();
virtual FX_BOOL Next(FX_BOOL bPrev = FALSE);
@@ -36,10 +32,6 @@ class CFDE_TxtEdtBufIter : public IFX_CharIter {
int32_t m_nCurChunk;
int32_t m_nCurIndex;
int32_t m_nIndex;
-#ifdef FDE_USEFORMATBLOCK
- FX_BOOL m_bForDisplay;
- int32_t m_nAliasCount;
-#endif
FX_WCHAR m_Alias;
};
class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf {
diff --git a/xfa/src/fee/src/fee/fde_txtedtengine.cpp b/xfa/src/fee/src/fee/fde_txtedtengine.cpp
index ed67442f07..f8b5444b70 100644
--- a/xfa/src/fee/src/fee/fde_txtedtengine.cpp
+++ b/xfa/src/fee/src/fee/fde_txtedtengine.cpp
@@ -15,24 +15,12 @@
#include "xfa/src/fdp/include/fde_tto.h"
#include "xfa/src/foxitlib.h"
-#ifdef FDE_USEFORMATBLOCK
-#include "xfa/src/fee/src/fee/fde_txtedtblock.h"
-#endif
-
#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
-#ifdef FDE_USEFORMATBLOCK
-#define FDE_TXTEDT_DORECORD_FORMATINS 3
-#define FDE_TXTEDT_DORECORD_FORMATDEL 4
-#define FDE_TXTEDT_DORECORD_FORMATREP 5
-#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9
-#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB
-#endif
-
IFDE_TxtEdtEngine* IFDE_TxtEdtEngine::Create() {
return new CFDE_TxtEdtEngine();
}
@@ -50,9 +38,6 @@ CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
m_bLock(FALSE),
m_nLimit(0),
m_wcAliasChar(L'*'),
-#ifdef FDE_USEFORMATBLOCK
- m_nFixLength(-1), // FIXME: no such member => USEFORMATBLOCK can't work.
-#endif
m_nFirstLineEnd(FDE_TXTEDIT_LINEEND_Auto),
m_bAutoLineEnd(TRUE),
m_wLineEnd(FDE_UNICODE_PARAGRAPH_SPERATOR) {
@@ -69,17 +54,6 @@ CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
m_pTextBreak->Release();
m_pTextBreak = NULL;
}
-#ifdef FDE_USEFORMATBLOCK
- int32_t nBlockCount = m_BlockArray.GetSize();
- if (nBlockCount > 0) {
- int32_t i = 0;
- for (; i < nBlockCount; i++) {
- CFDE_TxtEdtBlock* pBlock = m_BlockArray[i];
- delete pBlock;
- }
- m_BlockArray.RemoveAll();
- }
-#endif
RemoveAllParags();
RemoveAllPages();
m_Param.pEventSink = NULL;
@@ -172,50 +146,8 @@ void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText,
if (nCount == -1) {
nCount = nTextBufLength - nStart;
}
-#ifdef FDE_USEFORMATBLOCK
- int32_t nBlockCount = m_BlockArray.GetSize();
- if (nBlockCount == 0 || m_wsFixText.IsEmpty()) {
- m_pTxtBuf->GetRange(wsText, nStart, nCount);
- return;
- }
- CFX_WideString wsTemp;
- const FX_WCHAR* lpFixBuffer = const FX_WCHAR * (m_wsFixText);
- FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nTextBufLength);
- int32_t nRealLength = 0;
- int32_t nPrePos = 0;
- for (int32_t i = 0; i < nBlockCount; i++) {
- CFDE_TxtEdtBlock* pBlock = m_BlockArray[i];
- int32_t nPos = pBlock->GetPos();
- int32_t nCopyLength = nPos - nPrePos;
- FXSYS_memcpy(lpBuffer + nRealLength, lpFixBuffer + nPrePos,
- nCopyLength * sizeof(FX_WCHAR));
- nRealLength += nCopyLength;
- nPrePos = nPos;
- CFX_WideString wsBlock;
- pBlock->GetRealText(wsBlock);
- nCopyLength = wsBlock.GetLength();
- FXSYS_memcpy(lpBuffer + nRealLength, const FX_WCHAR*(wsBlock),
- nCopyLength * sizeof(FX_WCHAR));
- nRealLength += nCopyLength;
- }
- int32_t nLeftLength = m_wsFixText.GetLength() - nPrePos;
- if (nLeftLength > 0) {
- FXSYS_memcpy(lpBuffer + nRealLength, lpFixBuffer + nPrePos,
- nLeftLength * sizeof(FX_WCHAR));
- nRealLength += nLeftLength;
- }
- wsTemp.ReleaseBuffer(nRealLength);
- int32_t nRealBgn = GetRealIndex(nStart);
- int32_t nRealEnd = GetRealIndex(nStart + nCount - 1);
- int32_t nRealCount = nRealEnd - nRealBgn;
- FX_WCHAR* lpDestBuf = wsText.GetBuffer(nRealCount);
- FXSYS_memcpy(lpDestBuf, const FX_WCHAR*(wsTemp) + nRealBgn,
- nRealCount * sizeof(FX_WCHAR));
- wsText.ReleaseBuffer();
-#else
m_pTxtBuf->GetRange(wsText, nStart, nCount);
RecoverParagEnd(wsText);
-#endif
}
void CFDE_TxtEdtEngine::ClearText() {
@@ -239,11 +171,6 @@ int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
if (m_PagePtrArray.GetSize() <= m_nCaretPage) {
return 0;
}
-#ifdef FDE_USEFORMATBLOCK
- if (m_BlockArray.GetSize() > 0) {
- nIndex = NormalizeCaretPos(nIndex, FDE_FORMAT_CARET_MIDDLE, bBefore);
- }
-#endif
m_bBefore = bBefore;
m_nCaret = nIndex;
MovePage2Char(m_nCaret);
@@ -291,15 +218,6 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
} else {
FX_BOOL bBefore = TRUE;
int32_t nIndex = MoveBackward(bBefore);
-#ifdef FDE_USEFORMATBLOCK
- if (m_BlockArray.GetSize()) {
- nIndex =
- NormalizeCaretPos(nIndex, FDE_FORMAT_CARET_BACKWARD, bBefore);
- if (nIndex < 0) {
- return m_nCaret;
- }
- }
-#endif
if (nIndex >= 0) {
UpdateCaretRect(nIndex, bBefore);
}
@@ -314,14 +232,6 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
} else {
FX_BOOL bBefore = TRUE;
int32_t nIndex = MoveForward(bBefore);
-#ifdef FDE_USEFORMATBLOCK
- if (m_BlockArray.GetSize()) {
- if (nIndex == -1) {
- nIndex = GetTextBufLength();
- }
- nIndex = NormalizeCaretPos(nIndex, FDE_FORMAT_CARET_FORWARD, bBefore);
- }
-#endif
if (nIndex >= 0) {
UpdateCaretRect(nIndex, bBefore);
}
@@ -331,12 +241,6 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
if (bVertical) {
FX_BOOL bBefore = TRUE;
int32_t nIndex = MoveBackward(bBefore);
-#ifdef FDE_USEFORMATBLOCK
- if (m_BlockArray.GetSize()) {
- nIndex =
- NormalizeCaretPos(nIndex, FDE_FORMAT_CARET_BACKWARD, bBefore);
- }
-#endif
if (nIndex >= 0) {
UpdateCaretRect(nIndex, bBefore);
}
@@ -351,11 +255,6 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
if (bVertical) {
FX_BOOL bBefore = TRUE;
int32_t nIndex = MoveForward(bBefore);
-#ifdef FDE_USEFORMATBLOCK
- if (m_BlockArray.GetSize()) {
- nIndex = NormalizeCaretPos(nIndex, FDE_FORMAT_CARET_FORWARD, bBefore);
- }
-#endif
if (nIndex >= 0) {
UpdateCaretRect(nIndex, bBefore);
}
@@ -420,154 +319,6 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
if (IsLocked()) {
return FDE_TXTEDT_MODIFY_RET_F_Locked;
}
-#ifdef FDE_USEFORMATBLOCK
- int32_t nBlockCount = m_BlockArray.GetSize();
- if (nBlockCount) {
- if (m_Param.dwMode & FDE_TEXTEDITMODE_FIELD_TAB && nLength == 1 &&
- lpText[0] == L'\t') {
- return Move2NextEditableField(nStart) ? FDE_TXTEDT_MODIFY_RET_T_Tab
- : FDE_TXTEDT_MODIFY_RET_F_Tab;
- }
- int32_t nSelRangeCount = CountSelRanges();
- if (nSelRangeCount > 0) {
- if (nSelRangeCount > 1) {
- return FDE_TXTEDT_MODIFY_RET_F_Boundary;
- }
- int32_t nSelStart;
- int32_t nSelCount;
- nSelCount = GetSelRange(0, nSelStart);
- int32_t nSelEnd = nSelStart + nSelCount;
- int32_t nBgn = 0;
- int32_t nEnd = 0;
- CFDE_TxtEdtField* pField = NULL;
- FX_BOOL bInField = GetFieldBoundary(nSelStart, nBgn, nEnd, pField);
- if (nSelEnd > nEnd) {
- return FDE_TXTEDT_MODIFY_RET_F_Boundary;
- }
- if (bInField) {
- pField->Backup();
- FX_BOOL bBefore = FALSE;
- CFX_WideString wsDel;
- int32_t nCaret;
- int32_t nIndexInField = nSelStart - nBgn;
- int32_t nRet = pField->Replace(nSelStart - nBgn, nSelCount,
- CFX_WideStringC(lpText, nLength), wsDel,
- nCaret, bBefore);
- switch (nRet) {
- case FDE_FORMAT_FIELD_INSERT_RET_F_FULL:
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Full;
- case FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE:
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- default:
- break;
- }
- CFX_WideString wsField;
- pField->GetFieldText(wsField);
- if (!m_Param.pEventSink->On_ValidateField(this, pField->GetBlockIndex(),
- pField->GetIndex(), wsField,
- 0)) {
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
- CFX_WideString wsDisplay;
- pField->GetDisplayText(wsDisplay);
- if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) ||
- (m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) {
- CFX_WideString wsText;
- GetPreReplaceText(wsText, nBgn, nEnd - nBgn + 1,
- const FX_WCHAR*(wsDisplay), wsDisplay.GetLength());
- if (!IsFitArea(wsText)) {
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Full;
- }
- }
- Replace(nBgn, nEnd - nBgn + 1, wsDisplay);
- int32_t nNewCaret = nBgn + nCaret;
- if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_FieldReplace(
- this, m_nCaret, nNewCaret, pField, nIndexInField, nBgn,
- wsDisplay.GetLength(), wsDel, CFX_WideStringC(lpText, nLength),
- TRUE);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord);
- pRecord->Release();
- }
- SetCaretPos(nBgn + nCaret, bBefore);
- return FDE_TXTEDT_MODIFY_RET_S_Normal;
- }
- }
- int32_t nBgn = 0;
- int32_t nEnd = 0;
- CFDE_TxtEdtField* pField = NULL;
- FX_BOOL bInField = GetFieldBoundary(m_nCaret, nBgn, nEnd, pField);
- int32_t nCaretInField = m_nCaret - nBgn;
- FX_BOOL bBefore = FALSE;
- if (bInField) {
- pField->Backup();
- CFX_WideStringC wsIns(lpText, nLength);
- int32_t nRet =
- pField->Insert(nCaretInField, wsIns, nCaretInField, bBefore);
- FX_BOOL bFull = FALSE;
- switch (nRet) {
- case FDE_FORMAT_FIELD_INSERT_RET_S_NORMAL:
- break;
- case FDE_FORMAT_FIELD_INSERT_RET_S_FULL:
- bFull = TRUE;
- break;
- case FDE_FORMAT_FIELD_INSERT_RET_F_FULL:
- return FDE_TXTEDT_MODIFY_RET_F_Full;
- case FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE:
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- default:
- return FDE_TXTEDT_MODIFY_RET_F_Normal;
- }
- CFX_WideString wsField;
- pField->GetFieldText(wsField);
- if (!m_Param.pEventSink->On_ValidateField(
- this, pField->GetBlockIndex(), pField->GetIndex(), wsField, 0)) {
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
- CFX_WideString wsDisplay;
- pField->GetDisplayText(wsDisplay);
- if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) ||
- (m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) {
- CFX_WideString wsText;
- GetPreReplaceText(wsText, nBgn, nEnd - nBgn + 1,
- const FX_WCHAR*(wsDisplay), wsDisplay.GetLength());
- if (!IsFitArea(wsText)) {
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Full;
- }
- }
- Replace(nBgn, nEnd - nBgn + 1, wsDisplay);
- if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_FieldInsert(
- this, m_nCaret, pField, m_nCaret - nBgn, nBgn, nEnd - nBgn + 1,
- wsDisplay.GetLength(), CFX_WideStringC(lpText, nLength), FALSE);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord);
- pRecord->Release();
- }
- int32_t nCaretPos = nBgn + nCaretInField;
- if (m_Param.dwMode & FDE_TEXTEDITMODE_FIELD_AUTO && bFull &&
- nCaretPos == nEnd) {
- if (Move2NextEditableField(nEnd, TRUE, FALSE)) {
- return TRUE;
- }
- }
- SetCaretPos(nCaretPos, bBefore);
- return bFull ? FDE_TXTEDT_MODIFY_RET_S_Full
- : FDE_TXTEDT_MODIFY_RET_S_Normal;
- }
- FXSYS_assert(0);
- return FDE_TXTEDT_MODIFY_RET_F_Normal;
- }
-#endif
CFX_WideString wsTemp;
FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength);
FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR));
@@ -667,62 +418,7 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) {
DeleteSelect();
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
-#ifdef FDE_USEFORMATBLOCK
- int32_t nBlockCount = m_BlockArray.GetSize();
- if (nBlockCount > 0) {
- if (bBackspace) {
- nStart--;
- }
- int32_t nCount = 1;
- int32_t nBgn = 0;
- int32_t nEnd = 0;
- CFDE_TxtEdtField* pField = NULL;
- FX_BOOL bInField = GetFieldBoundary(nStart, nBgn, nEnd, pField);
- int32_t nCaretInField = nStart - nBgn;
- FX_BOOL bBefore = FALSE;
- if (bInField && !pField->IsFix()) {
- pField->Backup();
- CFX_WideString wsDel;
- int32_t nCaret = 0;
- int32_t nRet =
- pField->Delete(nCaretInField, nCount, wsDel, nCaret, bBefore);
- nCaret += nBgn;
- switch (nRet) {
- case FDE_FORMAT_FIELD_DELETE_RET_S:
- break;
- case FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE:
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- case FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY:
- return FDE_TXTEDT_MODIFY_RET_F_Boundary;
- default:
- FXSYS_assert(0);
- break;
- }
- CFX_WideString wsField;
- pField->GetFieldText(wsField);
- if (!m_Param.pEventSink->On_ValidateField(
- this, pField->GetBlockIndex(), pField->GetIndex(), wsField, 0)) {
- pField->Restore();
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
- CFX_WideString wsDisplay;
- pField->GetDisplayText(wsDisplay);
- Replace(nBgn, nEnd - nBgn + 1, wsDisplay);
- if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_FieldDelete(
- this, nStart, pField, nCaretInField, nBgn, nEnd - nBgn + 1,
- wsDisplay.GetLength(), wsDel, FALSE);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord);
- pRecord->Release();
- }
- SetCaretPos(nStart, bBefore);
- return FDE_TXTEDT_MODIFY_RET_S_Normal;
- }
- return FDE_TXTEDT_MODIFY_RET_F_Boundary;
- }
-#endif
+
int32_t nCount = 1;
if (bBackspace) {
if (nStart == 0) {
@@ -840,93 +536,7 @@ void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) {
void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) {
m_wcAliasChar = wcAlias;
}
-void CFDE_TxtEdtEngine::SetFormatBlock(int32_t nIndex,
- const CFX_WideString& wsBlockFormat) {
-#ifdef FDE_USEFORMATBLOCK
- if (m_nFixLength == -1) {
- m_nFixLength = GetTextLength();
- FXSYS_assert(m_wsFixText.IsEmpty());
- GetText(m_wsFixText, 0, -1);
- }
- FX_BOOL bInBlock = FALSE;
- int32_t nCharIndex = 0;
- int32_t nBlockIndex = 0;
- int32_t nBlockPos = -1;
- FX_WCHAR wc;
- CFDE_TxtEdtBufIter* pIter =
- new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf, FALSE);
- pIter->SetAt(0);
- do {
- wc = pIter->GetChar();
- if (bInBlock) {
- if (wc == FDE_TXTEDT_FORMATBLOCK_END) {
- nBlockIndex++;
- bInBlock = FALSE;
- }
- } else {
- if (wc == FDE_TXTEDT_FORMATBLOCK_BGN) {
- bInBlock = TRUE;
- } else {
- if (nCharIndex++ == nIndex) {
- nBlockPos = pIter->GetAt();
- break;
- }
- }
- }
- } while (pIter->Next());
- pIter->Release();
- if (nBlockPos == -1) {
- nBlockPos = GetTextBufLength();
- }
- CFDE_TxtEdtBlock* pEditBlock =
- new CFDE_TxtEdtBlock(this, wsBlockFormat, nIndex);
- m_BlockArray.InsertAt(m_BlockArray.GetSize(), pEditBlock);
- CFX_WideString wsDisplay;
- pEditBlock->GetDisplayText(wsDisplay);
- m_nCaret = nBlockPos;
- if (wsDisplay.GetLength() > 0) {
- RawInsert(nBlockPos, const FX_WCHAR*(wsDisplay), wsDisplay.GetLength());
- }
-#endif
-}
-int32_t CFDE_TxtEdtEngine::CountEditBlocks() const {
-#ifdef FDE_USEFORMATBLOCK
- return m_BlockArray.GetSize();
-#else
- return 0;
-#endif
-}
-void CFDE_TxtEdtEngine::GetEditBlockText(int32_t nIndex,
- CFX_WideString& wsBlockText) const {
-#ifdef FDE_USEFORMATBLOCK
- CFDE_TxtEdtBlock* pBlock = m_BlockArray[nIndex];
- pBlock->GetBlockText(wsBlockText);
-#endif
-}
-int32_t CFDE_TxtEdtEngine::CountEditFields(int32_t nBlockIndex) const {
-#ifdef FDE_USEFORMATBLOCK
- CFDE_TxtEdtBlock* pBlock = m_BlockArray[nBlockIndex];
- return pBlock->CountField();
-#else
- return 0;
-#endif
-}
-void CFDE_TxtEdtEngine::GetEditFieldText(int32_t nBlockIndex,
- int32_t nFieldIndex,
- CFX_WideString& wsFieldText) const {
-#ifdef FDE_USEFORMATBLOCK
- CFDE_TxtEdtBlock* pBlock = m_BlockArray[nBlockIndex];
- pBlock->GetFieldText(nFieldIndex, wsFieldText);
-#endif
-}
-void CFDE_TxtEdtEngine::StartEdit() {
-#ifdef FDE_USEFORMATBLOCK
-#endif
-}
-void CFDE_TxtEdtEngine::EndEdit() {
-#ifdef FDE_USEFORMATBLOCK
-#endif
-}
+
void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) {
FDE_LPTXTEDTSELRANGE lpTemp = NULL;
int32_t nRangeCount = m_SelRangePtrArr.GetSize();
@@ -1262,61 +872,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
UpdatePages();
}
-#ifdef FDE_USEFORMATBLOCK
-void CFDE_TxtEdtEngine::RawInsert(int32_t nStart,
- const FX_WCHAR* lpText,
- int32_t nLength) {
- FXSYS_assert(nLength > 0);
- FDE_TXTEDTPARAGPOS ParagPos;
- TextPos2ParagPos(nStart, ParagPos);
- int32_t nParagCount = m_ParagPtrArray.GetSize();
- int32_t i = 0;
- for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++) {
- m_ParagPtrArray[i]->m_nCharStart += nLength;
- }
- CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
- int32_t nReserveLineCount = pParag->m_nLineCount;
- int32_t nReserveCharStart = pParag->m_nCharStart;
- int32_t nLeavePart = ParagPos.nCharIndex;
- int32_t nCutPart = pParag->m_nCharCount - ParagPos.nCharIndex;
- int32_t nTextStart = 0;
- FX_WCHAR wCurChar = L' ';
- const FX_WCHAR* lpPos = lpText;
- FX_BOOL bFirst = TRUE;
- int32_t nParagIndex = ParagPos.nParagIndex;
- for (i = 0; i < nLength; i++, lpPos++) {
- wCurChar = *lpPos;
- if (wCurChar == m_wLineEnd) {
- if (bFirst) {
- pParag->m_nCharCount = nLeavePart + (i - nTextStart + 1);
- pParag->m_nLineCount = -1;
- nReserveCharStart += pParag->m_nCharCount;
- bFirst = FALSE;
- } else {
- pParag = new CFDE_TxtEdtParag(this);
- pParag->m_nLineCount = -1;
- pParag->m_nCharCount = i - nTextStart + 1;
- pParag->m_nCharStart = nReserveCharStart;
- m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
- nReserveCharStart += pParag->m_nCharCount;
- }
- nTextStart = i + 1;
- }
- }
- if (bFirst) {
- pParag->m_nCharCount += nLength;
- pParag->m_nLineCount = -1;
- bFirst = FALSE;
- } else {
- pParag = new CFDE_TxtEdtParag(this);
- pParag->m_nLineCount = -1;
- pParag->m_nCharCount = nLength - nTextStart + nCutPart;
- pParag->m_nCharStart = nReserveCharStart;
- m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
- }
- m_pTxtBuf->Insert(nStart, lpText, nLength);
-}
-#endif
+
void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
if (nCount == -1) {
nCount = m_pTxtBuf->GetTextLength() - nStart;
@@ -1380,11 +936,7 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
nCount = GetTextLength() - nStart;
}
FXSYS_assert((nStart + nCount) <= m_pTxtBuf->GetTextLength());
-#ifdef FDE_USEFORMATBLOCK
- int32_t nBlockCount = m_BlockArray.GetSize();
- if (nBlockCount > 0) {
- }
-#endif
+
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
CFX_WideString wsRange;
m_pTxtBuf->GetRange(wsRange, nStart, nCount);
@@ -1955,285 +1507,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveEnd() {
UpdateCaretRect(GetTextBufLength(), TRUE);
return TRUE;
}
-#ifdef FDE_USEFORMATBLOCK
-int32_t CFDE_TxtEdtEngine::NormalizeCaretPos(int32_t nIndex,
- int32_t nFlags,
- FX_BOOL& bBefore) {
- bBefore = TRUE;
- int32_t nBgn = 0, nEnd = 0;
- int32_t nRecord = -1;
- CFDE_TxtEdtField* pField = NULL;
- FX_BOOL bRet = GetFieldBoundary(nIndex, nBgn, nEnd, pField);
- int32_t nDelta = 0;
- if (bRet && !pField->IsFix()) {
- if (nIndex - nBgn < FDE_FORMAT_EDIT_FIELD_HADERSIZE) {
- if (nFlags == FDE_FORMAT_CARET_BACKWARD) {
- CFDE_TxtEdtField* pEditableField = NULL;
- if (FindEditableField(nIndex, nBgn, nEnd, pEditableField, FALSE)) {
- return pEditableField->NormalizeCaretPos(nEnd - nBgn,
- FDE_FORMAT_CARET_BACKWARD) +
- nBgn;
- }
- }
- nIndex = nBgn + FDE_FORMAT_EDIT_FIELD_HADERSIZE;
- }
- int32_t nRet = pField->NormalizeCaretPos(
- nIndex - nBgn, (FDE_FORMAT_CARET_DIRECTION)nFlags);
- if (nRet >= 0) {
- return nRet + nBgn;
- }
- if (nRet == -2) {
- int32_t nEditablePosBgn = 0, nEditablePosEnd = 0;
- pField->GetEditableRange(nEditablePosBgn, nEditablePosEnd);
- nRecord = nBgn + nEditablePosBgn;
- nFlags = FDE_FORMAT_CARET_BACKWARD;
- } else {
- FXSYS_assert(nRet == -1);
- int32_t nEditablePosBgn = 0, nEditablePosEnd = 0;
- pField->GetEditableRange(nEditablePosBgn, nEditablePosEnd);
- nRecord = nBgn + nEditablePosEnd;
- nFlags = FDE_FORMAT_CARET_FORWARD;
- }
- } else if (!bRet) {
- nDelta = FDE_FORMAT_EDIT_FIELD_HADERSIZE - FDE_FORMAT_EDIT_FIELD_TAILSIZE;
- }
- switch (nFlags) {
- case FDE_FORMAT_CARET_FORWARD: {
- if (FindEditableField(nIndex, nBgn, nEnd, pField)) {
- return pField->NormalizeCaretPos(FDE_FORMAT_EDIT_FIELD_HADERSIZE,
- FDE_FORMAT_CARET_FORWARD) +
- nBgn;
- } else {
- if (nRecord != -1) {
- return nRecord;
- }
- bRet = FindEditableField(nIndex, nBgn, nEnd, pField, FALSE);
- FXSYS_assert(bRet);
- return pField->NormalizeCaretPos(nEnd - nBgn,
- FDE_FORMAT_CARET_BACKWARD) +
- nBgn;
- }
- } break;
- case FDE_FORMAT_CARET_MIDDLE: {
- int32_t nBgn1 = 0, nEnd1 = 0, nBgn2 = 0, nEnd2 = 0;
- CFDE_TxtEdtField* pEditableField1 = NULL;
- CFDE_TxtEdtField* pEditableField2 = NULL;
- FX_BOOL bRet1 =
- FindEditableField(nIndex, nBgn1, nEnd1, pEditableField1, FALSE);
- FX_BOOL bRet2 = FindEditableField(nIndex, nBgn2, nEnd2, pEditableField2);
- if (bRet1 == FALSE) {
- FXSYS_assert(bRet2);
- return pEditableField2->NormalizeCaretPos(
- FDE_FORMAT_EDIT_FIELD_HADERSIZE, FDE_FORMAT_CARET_FORWARD) +
- nBgn2;
- } else if (bRet2 == FALSE) {
- FXSYS_assert(bRet1);
- return pEditableField1->NormalizeCaretPos(nEnd1 - nBgn1,
- FDE_FORMAT_CARET_BACKWARD) +
- nBgn1;
- } else {
- int32_t nEditablePosBgn = 0, nEditablePosEnd = 0;
- if (nIndex - nEnd1 < nBgn2 + nDelta - nIndex) {
- pEditableField1->GetEditableRange(nEditablePosBgn, nEditablePosEnd);
- return nEditablePosEnd + nBgn1;
- } else {
- pEditableField2->GetEditableRange(nEditablePosBgn, nEditablePosEnd);
- return nEditablePosBgn + nBgn2;
- }
- }
- } break;
- case FDE_FORMAT_CARET_BACKWARD: {
- if (FindEditableField(nIndex, nBgn, nEnd, pField, FALSE)) {
- return pField->NormalizeCaretPos(nEnd - nBgn,
- FDE_FORMAT_CARET_BACKWARD) +
- nBgn;
- } else {
- if (nRecord != -1) {
- return nRecord;
- }
- bRet = FindEditableField(nIndex, nBgn, nEnd, pField);
- FXSYS_assert(bRet);
- return pField->NormalizeCaretPos(FDE_FORMAT_EDIT_FIELD_HADERSIZE,
- FDE_FORMAT_CARET_FORWARD) +
- nBgn;
- }
- } break;
- default:
- FXSYS_assert(0);
- return nIndex;
- }
-}
-FX_BOOL CFDE_TxtEdtEngine::GetFieldBoundary(int32_t nIndex,
- int32_t& nBgn,
- int32_t& nEnd,
- CFDE_TxtEdtField*& pField) {
- CFDE_TxtEdtBufIter* pIter =
- new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf, FALSE);
- pIter->SetAt(nIndex);
- FX_BOOL bFind = FALSE;
- do {
- FX_WCHAR wc = pIter->GetChar();
- if (wc == FDE_TXTEDT_FORMATBLOCK_END) {
- nEnd = pIter->GetAt();
- bFind = TRUE;
- nIndex--;
- break;
- }
- if (wc == FDE_TXTEDT_FORMATBLOCK_BGN) {
- pIter->Release();
- return FALSE;
- }
- } while (pIter->Next());
- if (!bFind) {
- pIter->Release();
- return FALSE;
- }
- pIter->SetAt(nIndex);
- do {
- FX_WCHAR wc = pIter->GetChar();
- if (wc == FDE_TXTEDT_FORMATBLOCK_BGN) {
- nBgn = pIter->GetAt();
- pIter->Next();
- FX_DWORD dwPre = (FX_DWORD)pIter->GetChar();
- pIter->Next();
- FX_DWORD dwCur = (FX_DWORD)pIter->GetChar();
- pField = (CFDE_TxtEdtField*)((dwCur << 16) | dwPre);
- pIter->Release();
- return TRUE;
- }
- if (wc == FDE_TXTEDT_FORMATBLOCK_END) {
- pIter->Release();
- return FALSE;
- }
- } while (pIter->Next(TRUE));
- pIter->Release();
- return FALSE;
-}
-FX_BOOL CFDE_TxtEdtEngine::FindEditableField(int32_t nIndex,
- int32_t& nBgn,
- int32_t& nEnd,
- CFDE_TxtEdtField*& pField,
- FX_BOOL bForward) {
- FX_WCHAR wcFirst = FDE_TXTEDT_FORMATBLOCK_BGN;
- FX_WCHAR wcSecond = FDE_TXTEDT_FORMATBLOCK_END;
- if (!bForward) {
- wcFirst = FDE_TXTEDT_FORMATBLOCK_END;
- wcSecond = FDE_TXTEDT_FORMATBLOCK_BGN;
- }
- CFDE_TxtEdtBufIter* pIter =
- new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf, FALSE);
- pIter->SetAt(nIndex);
- int32_t bFind = FALSE;
- do {
- FX_WCHAR wc = pIter->GetChar();
- if (wc == wcFirst) {
- nBgn = pIter->GetAt();
- bFind = TRUE;
- break;
- }
- } while (pIter->Next(!bForward));
- if (!bFind) {
- pIter->Release();
- return FALSE;
- }
- bFind = FALSE;
- do {
- FX_WCHAR wc = pIter->GetChar();
- if (wc == wcSecond) {
- nEnd = pIter->GetAt();
- bFind = TRUE;
- break;
- }
- } while (pIter->Next(!bForward));
- FXSYS_assert(bFind);
- if (!bForward) {
- int32_t nTemp = nBgn;
- nBgn = nEnd;
- nEnd = nTemp;
- }
- pIter->SetAt(nBgn + 1);
- FX_DWORD dwPre = (FX_DWORD)pIter->GetChar();
- pIter->Next();
- FX_DWORD dwCur = (FX_DWORD)pIter->GetChar();
- pField = (CFDE_TxtEdtField*)((dwCur << 16) | dwPre);
- pIter->Release();
- if (!pField->IsFix()) {
- return TRUE;
- }
- return FindEditableField((bForward ? nEnd : nBgn), nBgn, nEnd, pField,
- bForward);
-}
-FX_BOOL CFDE_TxtEdtEngine::Move2NextEditableField(int32_t nIndex,
- FX_BOOL bForward,
- FX_BOOL bSelect) {
- if (m_SelRangePtrArr.GetSize() > 0) {
- ClearSelection();
- m_Param.pEventSink->On_SelChanged(this);
- }
- int32_t nBgn = 0, nEnd = 0;
- CFDE_TxtEdtField* pField = NULL;
- FX_BOOL bRet = FindEditableField(nIndex, nBgn, nEnd, pField, bForward);
- if (!bRet) {
- return FALSE;
- }
- int32_t nEditableBgn = 0, nEditableEnd = 0;
- pField->GetEditableRange(nEditableBgn, nEditableEnd);
- nEditableBgn += nBgn;
- nEditableEnd += nBgn;
- if (bSelect) {
- int32_t nRangeCount = nEditableEnd - nEditableBgn;
- if (nRangeCount > 0) {
- AddSelRange(nEditableBgn, nEditableEnd - nEditableBgn);
- }
- }
- SetCaretPos(nEditableEnd, TRUE);
- return TRUE;
-}
-int32_t CFDE_TxtEdtEngine::GetRealIndex(int32_t nIndex) const {
- CFDE_TxtEdtBufIter* pIter =
- new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf, FALSE);
- pIter->SetAt(0);
- FX_BOOL bInField = FALSE;
- int32_t nFieldBgn = 0;
- int32_t nRealIndex = 0;
- for (int32_t i = 0; i <= nIndex; i++) {
- FX_WCHAR wc = pIter->GetChar();
- if (bInField) {
- if (wc == FDE_TXTEDT_FORMATBLOCK_END) {
- FX_DWORD dwPre = (FX_DWORD)m_pTxtBuf->GetCharByIndex(nFieldBgn + 1);
- FX_DWORD dwCur = (FX_DWORD)m_pTxtBuf->GetCharByIndex(nFieldBgn + 2);
- CFDE_TxtEdtField* pField = (CFDE_TxtEdtField*)((dwCur << 16) | dwPre);
- nRealIndex += pField->GetFieldTextLength();
- bInField = FALSE;
- }
- } else {
- if (wc == FDE_TXTEDT_FORMATBLOCK_BGN) {
- bInField = TRUE;
- nFieldBgn = pIter->GetAt();
- } else {
- nRealIndex++;
- }
- }
- pIter->Next();
- }
- if (!bInField) {
- pIter->Release();
- return nRealIndex;
- }
- pIter->SetAt(nFieldBgn + 1);
- FX_DWORD dwPre = (FX_DWORD)pIter->GetChar();
- pIter->Next();
- FX_DWORD dwCur = (FX_DWORD)pIter->GetChar();
- CFDE_TxtEdtField* pField = (CFDE_TxtEdtField*)((dwCur << 16) | dwPre);
- pIter->Release();
- if (pField->IsFix()) {
- int32_t nDelta = nIndex - nFieldBgn - FDE_FORMAT_EDIT_FIELD_HADERSIZE + 1;
- return nRealIndex + (nDelta > 0 ? nDelta : 0);
- } else {
- return nRealIndex + pField->GetRealIndex(nIndex - nFieldBgn);
- }
-}
-#endif
+
FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
IFDE_TextOut* pTextOut = IFDE_TextOut::Create();
pTextOut->SetLineSpace(m_Param.fLineSpace);
@@ -2332,64 +1606,6 @@ FX_BOOL CFDE_TxtEdtEngine::IsSelect() {
void CFDE_TxtEdtEngine::DeleteSelect() {
int32_t nCountRange = CountSelRanges();
if (nCountRange > 0) {
-#ifdef FDE_USEFORMATBLOCK
- int32_t nBlockCount = m_BlockArray.GetSize();
- if (nBlockCount > 0) {
- if (nCountRange > 1) {
- return;
- }
- int32_t nSelStart;
- int32_t nSelCount;
- nSelCount = GetSelRange(0, nSelStart);
- int32_t nSelEnd = nSelStart + nSelCount;
- int32_t nBgn = 0;
- int32_t nEnd = 0;
- CFDE_TxtEdtField* pField = NULL;
- FX_BOOL bInField = GetFieldBoundary(nSelStart, nBgn, nEnd, pField);
- int32_t nCaretInField = nSelStart - nBgn;
- FX_BOOL bBefore = FALSE;
- if (!bInField || pField->IsFix() || nSelEnd > nEnd) {
- return;
- }
- pField->Backup();
- CFX_WideString wsDel;
- int32_t nCaret = 0;
- int32_t nRet =
- pField->Delete(nCaretInField, nSelCount, wsDel, nCaret, bBefore);
- nCaret += nBgn;
- switch (nRet) {
- case FDE_FORMAT_FIELD_DELETE_RET_S:
- break;
- case FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE:
- case FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY:
- return;
- default:
- FXSYS_assert(0);
- break;
- }
- CFX_WideString wsField;
- pField->GetFieldText(wsField);
- if (!m_Param.pEventSink->On_ValidateField(
- this, pField->GetBlockIndex(), pField->GetIndex(), wsField, 0)) {
- pField->Restore();
- return;
- }
- CFX_WideString wsDisplay;
- pField->GetDisplayText(wsDisplay);
- Replace(nBgn, nEnd - nBgn + 1, wsDisplay);
- if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_FieldDelete(
- this, nSelStart, pField, nCaretInField, nBgn, nEnd - nBgn + 1,
- wsDisplay.GetLength(), wsDel, FALSE);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord);
- pRecord->Release();
- }
- SetCaretPos(nSelStart, bBefore);
- return;
- }
-#endif
int32_t nSelStart;
int32_t nSelCount;
while (nCountRange > 0) {
@@ -2415,14 +1631,6 @@ IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create(
return new CFDE_TxtEdtDoRecord_Insert(bsDoRecord);
case FDE_TXTEDT_DORECORD_DEL:
return new CFDE_TxtEdtDoRecord_DeleteRange(bsDoRecord);
-#ifdef FDE_USEFORMATBLOCK
- case FDE_TXTEDT_DORECORD_FORMATINS:
- return new CFDE_TxtEdtDoRecord_FieldInsert(bsDoRecord);
- case FDE_TXTEDT_DORECORD_FORMATDEL:
- return new CFDE_TxtEdtDoRecord_FieldDelete(bsDoRecord);
- case FDE_TXTEDT_DORECORD_FORMATREP:
- return new CFDE_TxtEdtDoRecord_FieldReplace(bsDoRecord);
-#endif
default:
break;
}
@@ -2573,299 +1781,3 @@ void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize(
ArchiveLoader >> m_nCaret;
ArchiveLoader >> m_wsRange;
}
-#ifdef FDE_USEFORMATBLOCK
-CFDE_TxtEdtDoRecord_FieldInsert::CFDE_TxtEdtDoRecord_FieldInsert(
- const CFX_ByteStringC& bsDoRecord) {
- Deserialize(bsDoRecord);
-}
-CFDE_TxtEdtDoRecord_FieldInsert::CFDE_TxtEdtDoRecord_FieldInsert(
- CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- CFDE_TxtEdtField* pField,
- int32_t nIndexInField,
- int32_t nFieldBgn,
- int32_t nOldFieldLength,
- int32_t nNewFieldLength,
- const CFX_WideString& wsIns,
- FX_BOOL bSel)
- : m_pEngine(pEngine),
- m_nCaret(nCaret),
- m_pField(pField),
- m_nIndexInField(nIndexInField),
- m_nFieldBgn(nFieldBgn),
- m_nOldFieldLength(nOldFieldLength),
- m_nNewFieldLength(nNewFieldLength),
- m_wsIns(wsIns),
- m_bSel(bSel) {
- FXSYS_assert(pEngine);
- FXSYS_assert(pField);
-}
-CFDE_TxtEdtDoRecord_FieldInsert::~CFDE_TxtEdtDoRecord_FieldInsert() {}
-void CFDE_TxtEdtDoRecord_FieldInsert::Release() {
- delete this;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_FieldInsert::Undo() {
- CFX_WideString wsDel;
- int32_t nCaret = 0;
- FX_BOOL bBefore = FALSE;
- int32_t nRet = m_pField->Delete(m_nIndexInField, m_wsIns.GetLength(), wsDel,
- nCaret, bBefore);
- FXSYS_assert(nRet != FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE &&
- nRet != FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY);
- CFX_WideString wsDisplay;
- m_pField->GetDisplayText(wsDisplay);
- m_pEngine->Replace(m_nFieldBgn, m_nNewFieldLength, wsDisplay);
- m_pEngine->SetCaretPos(m_nCaret, TRUE);
- return TRUE;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_FieldInsert::Redo() {
- int32_t nCaret = 0;
- FX_BOOL bBefore = FALSE;
- int32_t nRet = m_pField->Insert(m_nIndexInField, m_wsIns, nCaret, bBefore);
- FXSYS_assert(nRet != FDE_FORMAT_FIELD_INSERT_RET_F_FULL &&
- nRet != FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE);
- CFX_WideString wsDisplay;
- m_pField->GetDisplayText(wsDisplay);
- m_pEngine->Replace(m_nFieldBgn, m_nOldFieldLength, wsDisplay);
- m_pEngine->SetCaretPos(m_nCaret + m_wsIns.GetLength(), TRUE);
- return TRUE;
-}
-void CFDE_TxtEdtDoRecord_FieldInsert::Serialize(
- CFX_ByteString& bsDoRecord) const {
- CFX_ArchiveSaver ArchiveSaver;
- ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_FORMATINS);
- ArchiveSaver << int32_t(m_pEngine);
- ArchiveSaver << m_nCaret;
- ArchiveSaver << int32_t(m_pField);
- ArchiveSaver << m_nIndexInField;
- ArchiveSaver << m_nFieldBgn;
- ArchiveSaver << m_nOldFieldLength;
- ArchiveSaver << m_nNewFieldLength;
- ArchiveSaver << m_wsIns;
- ArchiveSaver << m_bSel;
- int32_t nLength = ArchiveSaver.GetLength();
- const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer();
- FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength);
- FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength);
- bsDoRecord.ReleaseBuffer(nLength);
-}
-void CFDE_TxtEdtDoRecord_FieldInsert::Deserialize(
- const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(),
- bsDoRecord.GetLength());
- int32_t nType = 0;
- ArchiveLoader >> nType;
- FXSYS_assert(nType == FDE_TXTEDT_DORECORD_FORMATINS);
- int32_t nEngine = 0;
- ArchiveLoader >> nEngine;
- m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
- ArchiveLoader >> m_nCaret;
- int32_t nField = 0;
- ArchiveLoader >> nField;
- m_pField = (CFDE_TxtEdtField*)nField;
- ArchiveLoader >> m_nIndexInField;
- ArchiveLoader >> m_nFieldBgn;
- ArchiveLoader >> m_nOldFieldLength;
- ArchiveLoader >> m_nNewFieldLength;
- ArchiveLoader >> m_wsIns;
- ArchiveLoader >> m_bSel;
-}
-CFDE_TxtEdtDoRecord_FieldDelete::CFDE_TxtEdtDoRecord_FieldDelete(
- const CFX_ByteStringC& bsDoRecord) {
- Deserialize(bsDoRecord);
-}
-CFDE_TxtEdtDoRecord_FieldDelete::CFDE_TxtEdtDoRecord_FieldDelete(
- CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- CFDE_TxtEdtField* pField,
- int32_t nIndexInField,
- int32_t nFieldBgn,
- int32_t nOldLength,
- int32_t nNewLength,
- const CFX_WideString& wsDel,
- FX_BOOL bSel)
- : m_pEngine(pEngine),
- m_nCaret(nCaret),
- m_pField(pField),
- m_nIndexInField(nIndexInField),
- m_nFieldBgn(nFieldBgn),
- m_nOldFieldLength(nOldLength),
- m_nNewFieldLength(nNewLength),
- m_wsDel(wsDel),
- m_bSel(bSel) {
- FXSYS_assert(m_pEngine);
- FXSYS_assert(m_pField);
-}
-CFDE_TxtEdtDoRecord_FieldDelete::~CFDE_TxtEdtDoRecord_FieldDelete() {}
-void CFDE_TxtEdtDoRecord_FieldDelete::Release() {
- delete this;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_FieldDelete::Undo() {
- int32_t nCaret = 0;
- FX_BOOL bBefore = FALSE;
- int32_t nRet = m_pField->Insert(m_nIndexInField, m_wsDel, nCaret, bBefore);
- FXSYS_assert(nRet != FDE_FORMAT_FIELD_INSERT_RET_F_FULL &&
- nRet != FDE_FORMAT_FIELD_INSERT_RET_F_INVALIDATE);
- CFX_WideString wsDisplay;
- m_pField->GetDisplayText(wsDisplay);
- m_pEngine->Replace(m_nFieldBgn, m_nNewFieldLength, wsDisplay);
- m_pEngine->SetCaretPos(m_nCaret, TRUE);
- return TRUE;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_FieldDelete::Redo() {
- int32_t nCaret = 0;
- FX_BOOL bBefore = 0;
- CFX_WideString wsDel;
- int32_t nRet = m_pField->Delete(m_nIndexInField, m_wsDel.GetLength(), wsDel,
- nCaret, bBefore);
- FXSYS_assert(nRet != FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE &&
- nRet != FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY);
- CFX_WideString wsDisplay;
- m_pField->GetDisplayText(wsDisplay);
- m_pEngine->Replace(m_nFieldBgn, m_nOldFieldLength, wsDisplay);
- m_pEngine->SetCaretPos(m_nCaret - m_wsDel.GetLength(), TRUE);
- return TRUE;
-}
-void CFDE_TxtEdtDoRecord_FieldDelete::Serialize(
- CFX_ByteString& bsDoRecord) const {
- CFX_ArchiveSaver ArchiveSaver;
- ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_FORMATDEL);
- ArchiveSaver << int32_t(m_pEngine);
- ArchiveSaver << m_nCaret;
- ArchiveSaver << int32_t(m_pField);
- ArchiveSaver << m_nIndexInField;
- ArchiveSaver << m_nFieldBgn;
- ArchiveSaver << m_nOldFieldLength;
- ArchiveSaver << m_nNewFieldLength;
- ArchiveSaver << m_wsDel;
- ArchiveSaver << m_bSel;
- int32_t nLength = ArchiveSaver.GetLength();
- const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer();
- FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength);
- FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength);
- bsDoRecord.ReleaseBuffer(nLength);
-}
-void CFDE_TxtEdtDoRecord_FieldDelete::Deserialize(
- const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(),
- bsDoRecord.GetLength());
- int32_t nType = 0;
- ArchiveLoader >> nType;
- FXSYS_assert(nType == FDE_TXTEDT_DORECORD_FORMATDEL);
- int32_t nEngine = 0;
- ArchiveLoader >> nEngine;
- m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
- ArchiveLoader >> m_nCaret;
- int32_t nField = 0;
- ArchiveLoader >> nField;
- m_pField = (CFDE_TxtEdtField*)nField;
- ArchiveLoader >> m_nIndexInField;
- ArchiveLoader >> m_nFieldBgn;
- ArchiveLoader >> m_nOldFieldLength;
- ArchiveLoader >> m_nNewFieldLength;
- ArchiveLoader >> m_wsDel;
- ArchiveLoader >> m_bSel;
-}
-CFDE_TxtEdtDoRecord_FieldReplace::CFDE_TxtEdtDoRecord_FieldReplace(
- const CFX_ByteStringC& bsDoRecord) {
- Deserialize(bsDoRecord);
-}
-CFDE_TxtEdtDoRecord_FieldReplace::CFDE_TxtEdtDoRecord_FieldReplace(
- CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- int32_t nNewCaret,
- CFDE_TxtEdtField* pField,
- int32_t nIndexInField,
- int32_t nFieldBgn,
- int32_t nFieldNewLength,
- const CFX_WideString& wsDel,
- const CFX_WideString& wsIns,
- FX_BOOL bSel)
- : m_pEngine(pEngine),
- m_nCaret(nCaret),
- m_nNewCaret(nNewCaret),
- m_pField(pField),
- m_nIndexInField(nIndexInField),
- m_nFieldBgn(nFieldBgn),
- m_nFieldNewLength(nFieldNewLength),
- m_wsDel(wsDel),
- m_wsIns(wsIns),
- m_bSel(bSel) {
- FXSYS_assert(m_pEngine);
- FXSYS_assert(m_pField);
-}
-CFDE_TxtEdtDoRecord_FieldReplace::~CFDE_TxtEdtDoRecord_FieldReplace() {}
-void CFDE_TxtEdtDoRecord_FieldReplace::Release() {
- delete this;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_FieldReplace::Undo() {
- CFX_WideString wsDel;
- int32_t nCaret = 0;
- FX_BOOL bBefore = FALSE;
- int32_t nRet = m_pField->Replace(m_nIndexInField, m_wsIns.GetLength(),
- m_wsDel, wsDel, nCaret, bBefore);
- FXSYS_assert(nRet != FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE &&
- nRet != FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY);
- CFX_WideString wsDisplay;
- m_pField->GetDisplayText(wsDisplay);
- m_pEngine->Replace(m_nFieldBgn, m_nFieldNewLength, wsDisplay);
- m_pEngine->SetCaretPos(m_nCaret, TRUE);
- return TRUE;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_FieldReplace::Redo() {
- CFX_WideString wsDel;
- int32_t nCaret = 0;
- FX_BOOL bBefore = FALSE;
- int32_t nRet = m_pField->Replace(m_nIndexInField, m_wsDel.GetLength(),
- m_wsIns, wsDel, nCaret, bBefore);
- FXSYS_assert(nRet != FDE_FORMAT_FIELD_DELETE_RET_F_INVALIDATE &&
- nRet != FDE_FORMAT_FIELD_DELETE_RET_F_BOUNDARY);
- CFX_WideString wsDisplay;
- m_pField->GetDisplayText(wsDisplay);
- m_pEngine->Replace(m_nFieldBgn, m_nFieldNewLength, wsDisplay);
- m_pEngine->SetCaretPos(m_nNewCaret, TRUE);
- return TRUE;
-}
-void CFDE_TxtEdtDoRecord_FieldReplace::Serialize(
- CFX_ByteString& bsDoRecord) const {
- CFX_ArchiveSaver ArchiveSaver;
- ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_FORMATREP);
- ArchiveSaver << int32_t(m_pEngine);
- ArchiveSaver << m_nCaret;
- ArchiveSaver << m_nNewCaret;
- ArchiveSaver << int32_t(m_pField);
- ArchiveSaver << m_nIndexInField;
- ArchiveSaver << m_nFieldBgn;
- ArchiveSaver << m_nFieldNewLength;
- ArchiveSaver << m_wsDel;
- ArchiveSaver << m_wsIns;
- ArchiveSaver << m_bSel;
- int32_t nLength = ArchiveSaver.GetLength();
- const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer();
- FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength);
- FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength);
- bsDoRecord.ReleaseBuffer(nLength);
-}
-void CFDE_TxtEdtDoRecord_FieldReplace::Deserialize(
- const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(),
- bsDoRecord.GetLength());
- int32_t nType = 0;
- ArchiveLoader >> nType;
- FXSYS_assert(nType == FDE_TXTEDT_DORECORD_FORMATREP);
- int32_t nEngine = 0;
- ArchiveLoader >> nEngine;
- m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
- ArchiveLoader >> m_nCaret;
- ArchiveLoader >> m_nNewCaret;
- int32_t nField = 0;
- ArchiveLoader >> nField;
- m_pField = (CFDE_TxtEdtField*)nField;
- ArchiveLoader >> m_nIndexInField;
- ArchiveLoader >> m_nFieldBgn;
- ArchiveLoader >> m_nFieldNewLength;
- ArchiveLoader >> m_wsDel;
- ArchiveLoader >> m_wsIns;
- ArchiveLoader >> m_bSel;
-}
-#endif
diff --git a/xfa/src/fee/src/fee/fde_txtedtengine.h b/xfa/src/fee/src/fee/fde_txtedtengine.h
index fa114ba9bf..de836ca3b8 100644
--- a/xfa/src/fee/src/fee/fde_txtedtengine.h
+++ b/xfa/src/fee/src/fee/fde_txtedtengine.h
@@ -19,14 +19,7 @@ class IFX_CharIter;
class CFDE_TxtEdtEngine;
class CFDE_TxtEdtDoRecord_Insert;
class CFDE_TxtEdtDoRecord_DeleteRange;
-#ifdef FDE_USEFORMATBLOCK
-class CFDE_TxtEdtDoRecord_FormatInsert;
-class CFDE_TxtEdtDoRecord_FormatDelete;
-class CFDE_TxtEdtDoRecord_FormatReplace;
-class CFDE_TxtEdtDoRecord_FieldInsert;
-class CFDE_TxtEdtDoRecord_FieldDelete;
-class CFDE_TxtEdtDoRecord_FieldReplace;
-#endif
+
class IFDE_TxtEdtDoRecord {
public:
static IFDE_TxtEdtDoRecord* Create(const CFX_ByteStringC& bsDoRecord);
@@ -40,12 +33,6 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine {
friend class CFDE_TxtEdtDoRecord_Insert;
friend class CFDE_TxtEdtDoRecord_DeleteRange;
friend class CFDE_TxtEdtPage;
-#ifdef FDE_USEFORMATBLOCK
- friend class CFDE_TxtEdtDoRecord_FormatInsert;
- friend class CFDE_TxtEdtDoRecord_FormatDelete;
- friend class CFDE_TxtEdtDoRecord_FormatReplace;
- friend class CFDE_TxtEdtBlock;
-#endif
struct _FDE_TXTEDTSELRANGE {
int32_t nStart;
int32_t nCount;
@@ -99,17 +86,6 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine {
virtual void SetLimit(int32_t nLimit);
virtual void SetAliasChar(FX_WCHAR wcAlias);
- virtual void SetFormatBlock(int32_t nIndex,
- const CFX_WideString& wsBlockFormat);
- virtual int32_t CountEditBlocks() const;
- virtual void GetEditBlockText(int32_t nIndex,
- CFX_WideString& wsBlockText) const;
- virtual int32_t CountEditFields(int32_t nBlockIndex) const;
- virtual void GetEditFieldText(int32_t nBlockIndex,
- int32_t nFieldIndex,
- CFX_WideString& wsFieldText) const;
- virtual void StartEdit();
- virtual void EndEdit();
void RemoveSelRange(int32_t nStart, int32_t nCount = -1);
@@ -146,9 +122,6 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine {
private:
void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength);
-#ifdef FDE_USEFORMATBLOCK
- void RawInsert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength);
-#endif
void GetPreDeleteText(CFX_WideString& wsText,
int32_t nIndex,
int32_t nLength);
@@ -270,105 +243,5 @@ class CFDE_TxtEdtDoRecord_DeleteRange : public IFDE_TxtEdtDoRecord {
int32_t m_nCaret;
CFX_WideString m_wsRange;
};
-#ifdef FDE_USEFORMATBLOCK
-class CFDE_TxtEdtDoRecord_FieldInsert : public IFDE_TxtEdtDoRecord {
- public:
- CFDE_TxtEdtDoRecord_FieldInsert(const CFX_ByteStringC& bsDoRecord);
- CFDE_TxtEdtDoRecord_FieldInsert(CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- CFDE_TxtEdtField* pField,
- int32_t nIndexInField,
- int32_t nFieldBgn,
- int32_t nOldFieldLength,
- int32_t nNewFieldLength,
- const CFX_WideString& wsIns,
- FX_BOOL bSel = FALSE);
- virtual void Release();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual void Serialize(CFX_ByteString& bsDoRecord) const;
-
- protected:
- ~CFDE_TxtEdtDoRecord_FieldInsert();
- void Deserialize(const CFX_ByteStringC& bsDoRecord);
-
- private:
- CFDE_TxtEdtEngine* m_pEngine;
- int32_t m_nCaret;
- CFDE_TxtEdtField* m_pField;
- int32_t m_nIndexInField;
- int32_t m_nFieldBgn;
- int32_t m_nOldFieldLength;
- int32_t m_nNewFieldLength;
- CFX_WideString m_wsIns;
- FX_BOOL m_bSel;
-};
-class CFDE_TxtEdtDoRecord_FieldDelete : public IFDE_TxtEdtDoRecord {
- public:
- CFDE_TxtEdtDoRecord_FieldDelete(const CFX_ByteStringC& bsDoRecord);
- CFDE_TxtEdtDoRecord_FieldDelete(CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- CFDE_TxtEdtField* pField,
- int32_t nIndexInField,
- int32_t nFieldBgn,
- int32_t nOldLength,
- int32_t nNewLength,
- const CFX_WideString& wsDel,
- FX_BOOL bSel = FALSE);
- virtual void Release();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual void Serialize(CFX_ByteString& bsDoRecord) const;
-
- protected:
- ~CFDE_TxtEdtDoRecord_FieldDelete();
- void Deserialize(const CFX_ByteStringC& bsDoRecord);
-
- private:
- CFDE_TxtEdtEngine* m_pEngine;
- int32_t m_nCaret;
- CFDE_TxtEdtField* m_pField;
- int32_t m_nIndexInField;
- int32_t m_nFieldBgn;
- int32_t m_nOldFieldLength;
- int32_t m_nNewFieldLength;
- CFX_WideString m_wsDel;
- FX_BOOL m_bSel;
-};
-class CFDE_TxtEdtDoRecord_FieldReplace : public IFDE_TxtEdtDoRecord {
- public:
- CFDE_TxtEdtDoRecord_FieldReplace(const CFX_ByteStringC& bsDoRecord);
- CFDE_TxtEdtDoRecord_FieldReplace(CFDE_TxtEdtEngine* pEngine,
- int32_t nCaret,
- int32_t nNewCaret,
- CFDE_TxtEdtField* pField,
- int32_t nIndexInField,
- int32_t nFieldBgn,
- int32_t nFieldNewLength,
- const CFX_WideString& wsDel,
- const CFX_WideString& wsIns,
- FX_BOOL bSel);
- virtual void Release();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual void Serialize(CFX_ByteString& bsDoRecord) const;
-
- protected:
- ~CFDE_TxtEdtDoRecord_FieldReplace();
- void Deserialize(const CFX_ByteStringC& bsDoRecord);
-
- private:
- CFDE_TxtEdtEngine* m_pEngine;
- int32_t m_nCaret;
- int32_t m_nNewCaret;
- CFDE_TxtEdtField* m_pField;
- int32_t m_nIndexInField;
- int32_t m_nFieldBgn;
- int32_t m_nFieldNewLength;
- CFX_WideString m_wsDel;
- CFX_WideString m_wsIns;
- FX_BOOL m_bSel;
-};
-#endif
#endif // XFA_SRC_FEE_SRC_FEE_FDE_TXTEDTENGINE_H_