summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-05-18 06:09:33 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-18 06:09:33 -0700
commitbe9b8947d0090e20116822fe7caf5e7973d6b20a (patch)
treeb88d67f0ed52956ad5d918110f449ecffa2f2a87 /xfa
parent56286b311543331d02fee90b832d66389a307961 (diff)
downloadpdfium-be9b8947d0090e20116822fe7caf5e7973d6b20a.tar.xz
Pass objects instead of strings for undo/redo records.
Currently the Undo/Redo records are serialized as byte strings and stored into a CFX_ByteStringArray. They are deserialized when used. This CL removes the serialization and stores the objects in a deque of unique pointers. Review-Url: https://codereview.chromium.org/1980293004
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fee/fde_txtedtengine.cpp165
-rw-r--r--xfa/fee/fde_txtedtengine.h34
-rw-r--r--xfa/fwl/basewidget/fwl_comboboximp.cpp23
-rw-r--r--xfa/fwl/basewidget/fwl_comboboximp.h4
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp51
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.h25
-rw-r--r--xfa/fwl/basewidget/ifwl_combobox.h5
-rw-r--r--xfa/fwl/basewidget/ifwl_edit.h5
-rw-r--r--xfa/fwl/lightwidget/cfwl_combobox.cpp8
-rw-r--r--xfa/fwl/lightwidget/cfwl_combobox.h4
-rw-r--r--xfa/fwl/lightwidget/cfwl_edit.cpp12
-rw-r--r--xfa/fwl/lightwidget/cfwl_edit.h5
12 files changed, 114 insertions, 227 deletions
diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fee/fde_txtedtengine.cpp
index 826f0ce62c..d1d33fe8c6 100644
--- a/xfa/fee/fde_txtedtengine.cpp
+++ b/xfa/fee/fde_txtedtengine.cpp
@@ -383,14 +383,11 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
if (IsSelect()) {
DeleteSelect();
}
- if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- IFDE_TxtEdtDoRecord* pRecord =
- new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsStringC());
- pRecord->Release();
- }
+ if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo))
+ m_Param.pEventSink->On_AddDoRecord(
+ this,
+ new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength));
+
GetText(m_ChangeInfo.wsPrevText, 0);
Inner_Insert(m_nCaret, lpBuffer, nLength);
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
@@ -447,12 +444,9 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) {
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
CFX_WideString wsRange;
m_pTxtBuf->GetRange(wsRange, nStart, nCount);
- IFDE_TxtEdtDoRecord* pRecord =
- new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsStringC());
- pRecord->Release();
+ m_Param.pEventSink->On_AddDoRecord(
+ this,
+ new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange));
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
GetText(m_ChangeInfo.wsDelete, nStart, nCount);
@@ -634,38 +628,22 @@ void CFDE_TxtEdtEngine::ClearSelection() {
m_Param.pEventSink->On_SelChanged(this);
}
-FX_BOOL CFDE_TxtEdtEngine::Redo(const CFX_ByteStringC& bsRedo) {
- if (IsLocked()) {
+FX_BOOL CFDE_TxtEdtEngine::Redo(const IFDE_TxtEdtDoRecord* pDoRecord) {
+ if (IsLocked())
return FALSE;
- }
- if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) {
+ if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)
return FALSE;
- }
- IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsRedo);
- ASSERT(pDoRecord);
- if (pDoRecord == NULL) {
- return FALSE;
- }
- FX_BOOL bOK = pDoRecord->Redo();
- pDoRecord->Release();
- return bOK;
+ return pDoRecord->Redo();
}
-FX_BOOL CFDE_TxtEdtEngine::Undo(const CFX_ByteStringC& bsUndo) {
- if (IsLocked()) {
+
+FX_BOOL CFDE_TxtEdtEngine::Undo(const IFDE_TxtEdtDoRecord* pDoRecord) {
+ if (IsLocked())
return FALSE;
- }
- if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) {
+ if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)
return FALSE;
- }
- IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsUndo);
- ASSERT(pDoRecord);
- if (pDoRecord == NULL) {
- return FALSE;
- }
- FX_BOOL bOK = pDoRecord->Undo();
- pDoRecord->Release();
- return bOK;
+ return pDoRecord->Undo();
}
+
int32_t CFDE_TxtEdtEngine::StartLayout() {
Lock();
RemoveAllPages();
@@ -930,12 +908,9 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
CFX_WideString wsRange;
m_pTxtBuf->GetRange(wsRange, nStart, nCount);
- IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_DeleteRange(
- this, nStart, m_nCaret, wsRange, bSel);
- CFX_ByteString bsDoRecord;
- pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsStringC());
- pRecord->Release();
+ m_Param.pEventSink->On_AddDoRecord(
+ this, new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret,
+ wsRange, bSel));
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
GetText(m_ChangeInfo.wsDelete, nStart, nCount);
@@ -1601,24 +1576,6 @@ void CFDE_TxtEdtEngine::DeleteSelect() {
}
}
-IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create(
- const CFX_ByteStringC& bsDoRecord) {
- const uint32_t* lpBuf =
- reinterpret_cast<const uint32_t*>(bsDoRecord.raw_str());
- switch (*lpBuf) {
- case FDE_TXTEDT_DORECORD_INS:
- return new CFDE_TxtEdtDoRecord_Insert(bsDoRecord);
- case FDE_TXTEDT_DORECORD_DEL:
- return new CFDE_TxtEdtDoRecord_DeleteRange(bsDoRecord);
- default:
- return nullptr;
- }
-}
-
-CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
- const CFX_ByteStringC& bsDoRecord) {
- Deserialize(bsDoRecord);
-}
CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
CFDE_TxtEdtEngine* pEngine,
int32_t nCaret,
@@ -1630,11 +1587,10 @@ CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR));
m_wsInsert.ReleaseBuffer();
}
+
CFDE_TxtEdtDoRecord_Insert::~CFDE_TxtEdtDoRecord_Insert() {}
-void CFDE_TxtEdtDoRecord_Insert::Release() {
- delete this;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() {
+
+FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() const {
if (m_pEngine->IsSelect()) {
m_pEngine->ClearSelection();
}
@@ -1646,7 +1602,8 @@ FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() {
m_pEngine->SetCaretPos(m_nCaret, TRUE);
return TRUE;
}
-FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() {
+
+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;
@@ -1655,34 +1612,7 @@ FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() {
m_pEngine->SetCaretPos(m_nCaret, FALSE);
return TRUE;
}
-void CFDE_TxtEdtDoRecord_Insert::Serialize(CFX_ByteString& bsDoRecord) const {
- CFX_ArchiveSaver ArchiveSaver;
- ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_INS);
- ArchiveSaver << (int32_t)(uintptr_t)m_pEngine;
- ArchiveSaver << m_nCaret;
- ArchiveSaver << m_wsInsert;
- 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_Insert::Deserialize(
- const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
- int32_t nType = 0;
- ArchiveLoader >> nType;
- ASSERT(nType == FDE_TXTEDT_DORECORD_INS);
- int32_t nEngine = 0;
- ArchiveLoader >> nEngine;
- m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
- ArchiveLoader >> m_nCaret;
- ArchiveLoader >> m_wsInsert;
-}
-CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
- const CFX_ByteStringC& bsDoRecord) {
- Deserialize(bsDoRecord);
-}
+
CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
CFDE_TxtEdtEngine* pEngine,
int32_t nIndex,
@@ -1696,11 +1626,10 @@ CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
m_wsRange(wsRange) {
ASSERT(pEngine);
}
+
CFDE_TxtEdtDoRecord_DeleteRange::~CFDE_TxtEdtDoRecord_DeleteRange() {}
-void CFDE_TxtEdtDoRecord_DeleteRange::Release() {
- delete this;
-}
-FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() {
+
+FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() const {
if (m_pEngine->IsSelect()) {
m_pEngine->ClearSelection();
}
@@ -1715,7 +1644,8 @@ FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() {
m_pEngine->SetCaretPos(m_nCaret, TRUE);
return TRUE;
}
-FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Redo() {
+
+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());
@@ -1727,34 +1657,3 @@ FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Redo() {
m_pEngine->SetCaretPos(m_nIndex, TRUE);
return TRUE;
}
-void CFDE_TxtEdtDoRecord_DeleteRange::Serialize(
- CFX_ByteString& bsDoRecord) const {
- CFX_ArchiveSaver ArchiveSaver;
- ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_DEL);
- ArchiveSaver << (int32_t)(uintptr_t)m_pEngine;
- ArchiveSaver << (int32_t)m_bSel;
- ArchiveSaver << m_nIndex;
- ArchiveSaver << m_nCaret;
- ArchiveSaver << m_wsRange;
- 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_DeleteRange::Deserialize(
- const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
- int32_t nType = 0;
- ArchiveLoader >> nType;
- ASSERT(nType == FDE_TXTEDT_DORECORD_DEL);
- int32_t nEngine = 0;
- ArchiveLoader >> nEngine;
- m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
- int32_t iSel = 0;
- ArchiveLoader >> iSel;
- m_bSel = !!iSel;
- ArchiveLoader >> m_nIndex;
- ArchiveLoader >> m_nCaret;
- ArchiveLoader >> m_wsRange;
-}
diff --git a/xfa/fee/fde_txtedtengine.h b/xfa/fee/fde_txtedtengine.h
index 4671bf549a..585caa1eb6 100644
--- a/xfa/fee/fde_txtedtengine.h
+++ b/xfa/fee/fde_txtedtengine.h
@@ -20,12 +20,10 @@ class CFDE_TxtEdtDoRecord_DeleteRange;
class IFDE_TxtEdtDoRecord {
public:
- static IFDE_TxtEdtDoRecord* Create(const CFX_ByteStringC& bsDoRecord);
virtual ~IFDE_TxtEdtDoRecord() {}
- virtual void Release() = 0;
- virtual FX_BOOL Redo() = 0;
- virtual FX_BOOL Undo() = 0;
- virtual void Serialize(CFX_ByteString& bsDoRecord) const = 0;
+
+ virtual FX_BOOL Redo() const = 0;
+ virtual FX_BOOL Undo() const = 0;
};
class CFDE_TxtEdtEngine {
@@ -74,8 +72,8 @@ class CFDE_TxtEdtEngine {
int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
void ClearSelection();
- FX_BOOL Redo(const CFX_ByteStringC& bsRedo);
- FX_BOOL Undo(const CFX_ByteStringC& bsUndo);
+ FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord);
int32_t StartLayout();
int32_t DoLayout(IFX_Pause* pPause);
@@ -195,19 +193,14 @@ class CFDE_TxtEdtEngine {
class CFDE_TxtEdtDoRecord_Insert : public IFDE_TxtEdtDoRecord {
public:
- CFDE_TxtEdtDoRecord_Insert(const CFX_ByteStringC& bsDoRecord);
CFDE_TxtEdtDoRecord_Insert(CFDE_TxtEdtEngine* pEngine,
int32_t nCaret,
const FX_WCHAR* lpText,
int32_t nLength);
- virtual void Release();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual void Serialize(CFX_ByteString& bsDoRecord) const;
+ ~CFDE_TxtEdtDoRecord_Insert() override;
- protected:
- ~CFDE_TxtEdtDoRecord_Insert();
- void Deserialize(const CFX_ByteStringC& bsDoRecord);
+ FX_BOOL Undo() const override;
+ FX_BOOL Redo() const override;
private:
CFDE_TxtEdtEngine* m_pEngine;
@@ -217,20 +210,15 @@ class CFDE_TxtEdtDoRecord_Insert : public IFDE_TxtEdtDoRecord {
class CFDE_TxtEdtDoRecord_DeleteRange : public IFDE_TxtEdtDoRecord {
public:
- CFDE_TxtEdtDoRecord_DeleteRange(const CFX_ByteStringC& bsDoRecord);
CFDE_TxtEdtDoRecord_DeleteRange(CFDE_TxtEdtEngine* pEngine,
int32_t nIndex,
int32_t nCaret,
const CFX_WideString& wsRange,
FX_BOOL bSel = FALSE);
- virtual void Release();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual void Serialize(CFX_ByteString& bsDoRecord) const;
+ ~CFDE_TxtEdtDoRecord_DeleteRange() override;
- protected:
- ~CFDE_TxtEdtDoRecord_DeleteRange();
- void Deserialize(const CFX_ByteStringC& bsDoRecord);
+ FX_BOOL Undo() const override;
+ FX_BOOL Redo() const override;
private:
CFDE_TxtEdtEngine* m_pEngine;
diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp
index 81c2fa75d3..6af49d8021 100644
--- a/xfa/fwl/basewidget/fwl_comboboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp
@@ -69,11 +69,11 @@ FWL_Error IFWL_ComboBox::SetEditLimit(int32_t nLimit) {
FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDoClipboard(iCmd);
}
-FX_BOOL IFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) {
- return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(bsRecord);
+FX_BOOL IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(pRecord);
}
-FX_BOOL IFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) {
- return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(bsRecord);
+FX_BOOL IFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(pRecord);
}
IFWL_ListBox* IFWL_ComboBox::GetListBoxt() {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetListBoxt();
@@ -789,16 +789,15 @@ FWL_Error CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) {
return FWL_Error::Indefinite;
return m_pEdit->DoClipboard(iCmd);
}
-FX_BOOL CFWL_ComboBoxImp::EditRedo(const CFX_ByteStringC& bsRecord) {
- if (!m_pEdit)
- return FALSE;
- return m_pEdit->Redo(bsRecord);
+
+FX_BOOL CFWL_ComboBoxImp::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return m_pEdit && m_pEdit->Redo(pRecord);
}
-FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) {
- if (!m_pEdit)
- return FALSE;
- return m_pEdit->Undo(bsRecord);
+
+FX_BOOL CFWL_ComboBoxImp::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return m_pEdit && m_pEdit->Undo(pRecord);
}
+
IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() {
return m_pListBox.get();
}
diff --git a/xfa/fwl/basewidget/fwl_comboboximp.h b/xfa/fwl/basewidget/fwl_comboboximp.h
index 45cb47d321..42452e6871 100644
--- a/xfa/fwl/basewidget/fwl_comboboximp.h
+++ b/xfa/fwl/basewidget/fwl_comboboximp.h
@@ -117,8 +117,8 @@ class CFWL_ComboBoxImp : public CFWL_WidgetImp {
int32_t GetEditLimit();
FWL_Error SetEditLimit(int32_t nLimit);
FWL_Error EditDoClipboard(int32_t iCmd);
- FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
- FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
+ FX_BOOL EditRedo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL EditUndo(const IFDE_TxtEdtDoRecord* pRecord);
IFWL_ListBox* GetListBoxt();
FX_BOOL AfterFocusShowDropList();
FWL_Error OpenDropDownList(FX_BOOL bActivate);
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index 1e0fede4be..2d7d50580d 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -148,11 +148,11 @@ FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) {
FX_BOOL IFWL_Edit::Delete() {
return static_cast<CFWL_EditImp*>(GetImpl())->Delete();
}
-FX_BOOL IFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) {
- return static_cast<CFWL_EditImp*>(GetImpl())->Redo(bsRecord);
+FX_BOOL IFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return static_cast<CFWL_EditImp*>(GetImpl())->Redo(pRecord);
}
-FX_BOOL IFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
- return static_cast<CFWL_EditImp*>(GetImpl())->Undo(bsRecord);
+FX_BOOL IFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return static_cast<CFWL_EditImp*>(GetImpl())->Undo(pRecord);
}
FX_BOOL IFWL_Edit::Undo() {
return static_cast<CFWL_EditImp*>(GetImpl())->Undo();
@@ -749,36 +749,32 @@ FX_BOOL CFWL_EditImp::Delete() {
return TRUE;
}
-FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) {
+FX_BOOL CFWL_EditImp::Redo(const IFDE_TxtEdtDoRecord* pRecord) {
if (!m_pEdtEngine)
return FALSE;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo)
return TRUE;
- return m_pEdtEngine->Redo(bsRecord);
+ return m_pEdtEngine->Redo(pRecord);
}
-FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) {
+FX_BOOL CFWL_EditImp::Undo(const IFDE_TxtEdtDoRecord* pRecord) {
if (!m_pEdtEngine)
return FALSE;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo)
return TRUE;
- return m_pEdtEngine->Undo(bsRecord);
+ return m_pEdtEngine->Undo(pRecord);
}
FX_BOOL CFWL_EditImp::Undo() {
if (!CanUndo())
return FALSE;
-
- CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--];
- return Undo(bsRecord.AsStringC());
+ return Undo(m_DoRecords[m_iCurRecord--].get());
}
FX_BOOL CFWL_EditImp::Redo() {
if (!CanRedo())
return FALSE;
-
- CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord];
- return Redo(bsRecord.AsStringC());
+ return Redo(m_DoRecords[++m_iCurRecord].get());
}
FX_BOOL CFWL_EditImp::CanUndo() {
@@ -786,7 +782,7 @@ FX_BOOL CFWL_EditImp::CanUndo() {
}
FX_BOOL CFWL_EditImp::CanRedo() {
- return m_iCurRecord < m_RecordArr.GetSize() - 1;
+ return m_iCurRecord < m_DoRecords.size() - 1;
}
FWL_Error CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
@@ -931,8 +927,8 @@ FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
}
void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
- const CFX_ByteStringC& bsDoRecord) {
- AddDoRecord(bsDoRecord);
+ IFDE_TxtEdtDoRecord* pRecord) {
+ AddDoRecord(pRecord);
}
FX_BOOL CFWL_EditImp::On_Validate(CFDE_TxtEdtEngine* pEdit,
@@ -1468,20 +1464,21 @@ FX_BOOL CFWL_EditImp::IsContentHeightOverflow() {
return FALSE;
return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f;
}
-int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord) {
- int32_t nCount = m_RecordArr.GetSize();
+int32_t CFWL_EditImp::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) {
+ int32_t nCount = m_DoRecords.size();
if (m_iCurRecord == nCount - 1) {
if (nCount == m_iMaxRecord) {
- m_RecordArr.RemoveAt(0);
+ m_DoRecords.pop_front();
m_iCurRecord--;
}
} else {
- for (int32_t i = nCount - 1; i > m_iCurRecord; i--) {
- m_RecordArr.RemoveAt(i);
- }
+ m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1,
+ m_DoRecords.end());
}
- m_RecordArr.Add(CFX_ByteString(bsDoRecord));
- return m_iCurRecord = m_RecordArr.GetSize() - 1;
+
+ m_DoRecords.push_back(std::unique_ptr<IFDE_TxtEdtDoRecord>(pRecord));
+ m_iCurRecord = m_DoRecords.size() - 1;
+ return m_iCurRecord;
}
void CFWL_EditImp::Layout() {
GetClientRect(m_rtClient);
@@ -1736,10 +1733,12 @@ void CFWL_EditImp::InitCaret() {
m_pCaret.reset();
}
}
+
void CFWL_EditImp::ClearRecord() {
m_iCurRecord = -1;
- m_RecordArr.RemoveAll();
+ m_DoRecords.clear();
}
+
void CFWL_EditImp::ProcessInsertError(int32_t iError) {
switch (iError) {
case -2: {
diff --git a/xfa/fwl/basewidget/fwl_editimp.h b/xfa/fwl/basewidget/fwl_editimp.h
index 9c0853b4fd..484c1f8841 100644
--- a/xfa/fwl/basewidget/fwl_editimp.h
+++ b/xfa/fwl/basewidget/fwl_editimp.h
@@ -7,6 +7,7 @@
#ifndef XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_
+#include <deque>
#include <memory>
#include <vector>
@@ -15,14 +16,15 @@
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fxgraphics/cfx_path.h"
+class CFWL_EditImp;
+class CFWL_EditImpDelegate;
class CFWL_MsgActivate;
class CFWL_MsgDeactivate;
class CFWL_MsgMouse;
-class CFWL_WidgetImpProperties;
class CFWL_WidgetImpDelegate;
+class CFWL_WidgetImpProperties;
+class IFDE_TxtEdtDoRecord;
class IFWL_Caret;
-class CFWL_EditImp;
-class CFWL_EditImpDelegate;
class CFWL_EditImp : public CFWL_WidgetImp {
public:
@@ -71,8 +73,8 @@ class CFWL_EditImp : public CFWL_WidgetImp {
virtual FX_BOOL Cut(CFX_WideString& wsCut);
virtual FX_BOOL Paste(const CFX_WideString& wsPaste);
virtual FX_BOOL Delete();
- virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
- virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
+ virtual FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord);
+ virtual FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord);
virtual FX_BOOL Undo();
virtual FX_BOOL Redo();
virtual FX_BOOL CanUndo();
@@ -95,8 +97,7 @@ class CFWL_EditImp : public CFWL_WidgetImp {
FX_BOOL On_PageUnload(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose);
- void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
- const CFX_ByteStringC& bsDoRecord);
+ void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtDoRecord* pRecord);
FX_BOOL On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText);
void SetScrollOffset(FX_FLOAT fScrollOffset);
FX_BOOL GetSuggestWords(CFX_PointF pointf,
@@ -105,6 +106,9 @@ class CFWL_EditImp : public CFWL_WidgetImp {
const CFX_ByteStringC& bsReplace);
protected:
+ friend class CFWL_TxtEdtEventSink;
+ friend class CFWL_EditImpDelegate;
+
void DrawTextBk(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix = NULL);
@@ -130,7 +134,7 @@ class CFWL_EditImp : public CFWL_WidgetImp {
void ClearRecord();
FX_BOOL IsShowScrollBar(FX_BOOL bVert);
FX_BOOL IsContentHeightOverflow();
- int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord);
+ int32_t AddDoRecord(IFDE_TxtEdtDoRecord* pRecord);
void ProcessInsertError(int32_t iError);
void DrawSpellCheck(CFX_Graphics* pGraphics,
@@ -141,6 +145,7 @@ class CFWL_EditImp : public CFWL_WidgetImp {
FX_FLOAT fOffSetX,
FX_FLOAT fOffSetY);
int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount);
+
CFX_RectF m_rtClient;
CFX_RectF m_rtEngine;
CFX_RectF m_rtStatic;
@@ -162,12 +167,10 @@ class CFWL_EditImp : public CFWL_WidgetImp {
std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar;
std::unique_ptr<IFWL_Caret> m_pCaret;
CFX_WideString m_wsCache;
- friend class CFWL_TxtEdtEventSink;
- friend class CFWL_EditImpDelegate;
uint32_t m_backColor;
FX_BOOL m_updateBackColor;
CFX_WideString m_wsFont;
- CFX_ByteStringArray m_RecordArr;
+ std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords;
int32_t m_iCurRecord;
int32_t m_iMaxRecord;
};
diff --git a/xfa/fwl/basewidget/ifwl_combobox.h b/xfa/fwl/basewidget/ifwl_combobox.h
index 916e60b5bb..9755fc7686 100644
--- a/xfa/fwl/basewidget/ifwl_combobox.h
+++ b/xfa/fwl/basewidget/ifwl_combobox.h
@@ -11,6 +11,7 @@
#include "xfa/fxgraphics/include/cfx_graphics.h"
class CFWL_WidgetImpProperties;
+class IFDE_TxtEdtDoRecord;
class IFWL_ComboBox;
#define FWL_CLASS_ComboBox L"FWL_COMBOBOX"
@@ -90,8 +91,8 @@ class IFWL_ComboBox : public IFWL_Widget {
int32_t GetEditLimit();
FWL_Error SetEditLimit(int32_t nLimit);
FWL_Error EditDoClipboard(int32_t iCmd);
- FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
- FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
+ FX_BOOL EditRedo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL EditUndo(const IFDE_TxtEdtDoRecord* pRecord);
IFWL_ListBox* GetListBoxt();
FX_BOOL AfterFocusShowDropList();
FWL_Error OpenDropDownList(FX_BOOL bActivate);
diff --git a/xfa/fwl/basewidget/ifwl_edit.h b/xfa/fwl/basewidget/ifwl_edit.h
index 5650bce4dc..4cd0ab2d88 100644
--- a/xfa/fwl/basewidget/ifwl_edit.h
+++ b/xfa/fwl/basewidget/ifwl_edit.h
@@ -91,6 +91,7 @@ std::vector<CFX_ByteString> bsArraySuggestWords;
END_FWL_EVENT_DEF
class CFWL_WidgetImpProperties;
+class IFDE_TxtEdtDoRecord;
class IFWL_EditDP : public IFWL_DataProvider {};
@@ -128,8 +129,8 @@ class IFWL_Edit : public IFWL_Widget {
FX_BOOL Cut(CFX_WideString& wsCut);
FX_BOOL Paste(const CFX_WideString& wsPaste);
FX_BOOL Delete();
- FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
- FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
+ FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord);
FX_BOOL Undo();
FX_BOOL Redo();
FX_BOOL CanUndo();
diff --git a/xfa/fwl/lightwidget/cfwl_combobox.cpp b/xfa/fwl/lightwidget/cfwl_combobox.cpp
index ca88a23429..d70113b18a 100644
--- a/xfa/fwl/lightwidget/cfwl_combobox.cpp
+++ b/xfa/fwl/lightwidget/cfwl_combobox.cpp
@@ -140,16 +140,16 @@ FWL_Error CFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
return static_cast<IFWL_ComboBox*>(m_pIface)->EditDoClipboard(iCmd);
}
-FX_BOOL CFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) {
+FX_BOOL CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
if (!m_pIface)
return FALSE;
- return static_cast<IFWL_ComboBox*>(m_pIface)->EditRedo(bsRecord);
+ return static_cast<IFWL_ComboBox*>(m_pIface)->EditRedo(pRecord);
}
-FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) {
+FX_BOOL CFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
if (!m_pIface)
return FALSE;
- return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(bsRecord);
+ return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(pRecord);
}
FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
diff --git a/xfa/fwl/lightwidget/cfwl_combobox.h b/xfa/fwl/lightwidget/cfwl_combobox.h
index 5a639e33d9..b5d0327ba9 100644
--- a/xfa/fwl/lightwidget/cfwl_combobox.h
+++ b/xfa/fwl/lightwidget/cfwl_combobox.h
@@ -40,8 +40,8 @@ class CFWL_ComboBox : public CFWL_Widget {
int32_t GetEditLimit();
FWL_Error SetEditLimit(int32_t nLimit);
FWL_Error EditDoClipboard(int32_t iCmd);
- FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
- FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
+ FX_BOOL EditRedo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL EditUndo(const IFDE_TxtEdtDoRecord* pRecord);
FWL_Error SetMaxListHeight(FX_FLOAT fMaxHeight);
FWL_Error SetItemData(int32_t iIndex, void* pData);
void* GetItemData(int32_t iIndex);
diff --git a/xfa/fwl/lightwidget/cfwl_edit.cpp b/xfa/fwl/lightwidget/cfwl_edit.cpp
index f151edd7e9..f1471ea13b 100644
--- a/xfa/fwl/lightwidget/cfwl_edit.cpp
+++ b/xfa/fwl/lightwidget/cfwl_edit.cpp
@@ -154,16 +154,12 @@ FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) {
return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd);
}
-FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) {
- if (!m_pIface)
- return FALSE;
- return static_cast<IFWL_Edit*>(m_pIface)->Redo(bsRecord);
+FX_BOOL CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return m_pIface && static_cast<IFWL_Edit*>(m_pIface)->Redo(pRecord);
}
-FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
- if (!m_pIface)
- return FALSE;
- return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord);
+FX_BOOL CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return m_pIface && static_cast<IFWL_Edit*>(m_pIface)->Undo(pRecord);
}
FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
diff --git a/xfa/fwl/lightwidget/cfwl_edit.h b/xfa/fwl/lightwidget/cfwl_edit.h
index c7001a3166..349b380670 100644
--- a/xfa/fwl/lightwidget/cfwl_edit.h
+++ b/xfa/fwl/lightwidget/cfwl_edit.h
@@ -12,6 +12,7 @@
#include "xfa/fwl/lightwidget/cfwl_widget.h"
class CFWL_WidgetProperties;
+class IFDE_TxtEdtDoRecord;
class CFWL_Edit : public CFWL_Widget {
public:
@@ -40,8 +41,8 @@ class CFWL_Edit : public CFWL_Widget {
int32_t nLen,
const CFX_WideStringC& wsReplace);
FWL_Error DoClipboard(int32_t iCmd);
- FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
- FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
+ FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord);
FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
FWL_Error SetNumberRange(int32_t iMin, int32_t iMax);
FWL_Error SetBackColor(uint32_t dwColor);