diff options
author | dsinclair <dsinclair@chromium.org> | 2016-05-18 11:09:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-18 11:09:47 -0700 |
commit | 653951828cf934afb48b57989089a99b38620d02 (patch) | |
tree | 8a91b6f3ffac3d992e47e5d6fd4da31245597ff9 /xfa/fde/cfde_txtedtdorecord_insert.cpp | |
parent | 3b093630d55ad97807bcc710227b03819944605b (diff) | |
download | pdfium-653951828cf934afb48b57989089a99b38620d02.tar.xz |
Split xfa/fee files into individual class files.
This CL splits the xfa/fee files into individual class files and moves them
into the xfa/fde directory where they belong.
Review-Url: https://codereview.chromium.org/1994693002
Diffstat (limited to 'xfa/fde/cfde_txtedtdorecord_insert.cpp')
-rw-r--r-- | xfa/fde/cfde_txtedtdorecord_insert.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xfa/fde/cfde_txtedtdorecord_insert.cpp b/xfa/fde/cfde_txtedtdorecord_insert.cpp new file mode 100644 index 0000000000..1505d14f95 --- /dev/null +++ b/xfa/fde/cfde_txtedtdorecord_insert.cpp @@ -0,0 +1,47 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fde/cfde_txtedtdorecord_insert.h" + +#include "xfa/fde/cfde_txtedtengine.h" +#include "xfa/fwl/basewidget/fwl_editimp.h" + +CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( + CFDE_TxtEdtEngine* pEngine, + int32_t nCaret, + const FX_WCHAR* lpText, + int32_t nLength) + : m_pEngine(pEngine), m_nCaret(nCaret) { + ASSERT(pEngine); + FX_WCHAR* lpBuffer = m_wsInsert.GetBuffer(nLength); + FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR)); + m_wsInsert.ReleaseBuffer(); +} + +CFDE_TxtEdtDoRecord_Insert::~CFDE_TxtEdtDoRecord_Insert() {} + +FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() const { + if (m_pEngine->IsSelect()) + m_pEngine->ClearSelection(); + + m_pEngine->Inner_DeleteRange(m_nCaret, m_wsInsert.GetLength()); + FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; + m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; + m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; + Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + m_pEngine->SetCaretPos(m_nCaret, TRUE); + return TRUE; +} + +FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() const { + m_pEngine->Inner_Insert(m_nCaret, m_wsInsert.c_str(), m_wsInsert.GetLength()); + FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; + m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; + m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; + Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + m_pEngine->SetCaretPos(m_nCaret, FALSE); + return TRUE; +} |