Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: xfa/fee/fde_txtedtengine.cpp

Issue 1972053003: Add CFX_ByteStringC::CharAt() to avoid c_str() and casts (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fee/fde_txtedtengine.h" 7 #include "xfa/fee/fde_txtedtengine.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 ClearSelection(); 1596 ClearSelection();
1597 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); 1597 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
1598 m_Param.pEventSink->On_SelChanged(this); 1598 m_Param.pEventSink->On_SelChanged(this);
1599 SetCaretPos(nSelStart, TRUE); 1599 SetCaretPos(nSelStart, TRUE);
1600 return; 1600 return;
1601 } 1601 }
1602 } 1602 }
1603 1603
1604 IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create( 1604 IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create(
1605 const CFX_ByteStringC& bsDoRecord) { 1605 const CFX_ByteStringC& bsDoRecord) {
1606 const FX_CHAR* lpBuf = bsDoRecord.c_str(); 1606 const uint32_t* lpBuf =
1607 int32_t nType = *((int32_t*)lpBuf); 1607 reinterpret_cast<const uint32_t*>(bsDoRecord.raw_str());
1608 switch (nType) { 1608 switch (*lpBuf) {
1609 case FDE_TXTEDT_DORECORD_INS: 1609 case FDE_TXTEDT_DORECORD_INS:
1610 return new CFDE_TxtEdtDoRecord_Insert(bsDoRecord); 1610 return new CFDE_TxtEdtDoRecord_Insert(bsDoRecord);
1611 case FDE_TXTEDT_DORECORD_DEL: 1611 case FDE_TXTEDT_DORECORD_DEL:
1612 return new CFDE_TxtEdtDoRecord_DeleteRange(bsDoRecord); 1612 return new CFDE_TxtEdtDoRecord_DeleteRange(bsDoRecord);
1613 default: 1613 default:
1614 return nullptr; 1614 return nullptr;
1615 } 1615 }
1616 } 1616 }
1617 1617
1618 CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( 1618 CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 ArchiveSaver << m_nCaret; 1662 ArchiveSaver << m_nCaret;
1663 ArchiveSaver << m_wsInsert; 1663 ArchiveSaver << m_wsInsert;
1664 int32_t nLength = ArchiveSaver.GetLength(); 1664 int32_t nLength = ArchiveSaver.GetLength();
1665 const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer(); 1665 const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer();
1666 FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength); 1666 FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength);
1667 FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength); 1667 FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength);
1668 bsDoRecord.ReleaseBuffer(nLength); 1668 bsDoRecord.ReleaseBuffer(nLength);
1669 } 1669 }
1670 void CFDE_TxtEdtDoRecord_Insert::Deserialize( 1670 void CFDE_TxtEdtDoRecord_Insert::Deserialize(
1671 const CFX_ByteStringC& bsDoRecord) { 1671 const CFX_ByteStringC& bsDoRecord) {
1672 CFX_ArchiveLoader ArchiveLoader( 1672 CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
1673 reinterpret_cast<const uint8_t*>(bsDoRecord.c_str()),
1674 bsDoRecord.GetLength());
1675 int32_t nType = 0; 1673 int32_t nType = 0;
1676 ArchiveLoader >> nType; 1674 ArchiveLoader >> nType;
1677 ASSERT(nType == FDE_TXTEDT_DORECORD_INS); 1675 ASSERT(nType == FDE_TXTEDT_DORECORD_INS);
1678 int32_t nEngine = 0; 1676 int32_t nEngine = 0;
1679 ArchiveLoader >> nEngine; 1677 ArchiveLoader >> nEngine;
1680 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; 1678 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
1681 ArchiveLoader >> m_nCaret; 1679 ArchiveLoader >> m_nCaret;
1682 ArchiveLoader >> m_wsInsert; 1680 ArchiveLoader >> m_wsInsert;
1683 } 1681 }
1684 CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange( 1682 CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 ArchiveSaver << m_nCaret; 1737 ArchiveSaver << m_nCaret;
1740 ArchiveSaver << m_wsRange; 1738 ArchiveSaver << m_wsRange;
1741 int32_t nLength = ArchiveSaver.GetLength(); 1739 int32_t nLength = ArchiveSaver.GetLength();
1742 const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer(); 1740 const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer();
1743 FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength); 1741 FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength);
1744 FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength); 1742 FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength);
1745 bsDoRecord.ReleaseBuffer(nLength); 1743 bsDoRecord.ReleaseBuffer(nLength);
1746 } 1744 }
1747 void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize( 1745 void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize(
1748 const CFX_ByteStringC& bsDoRecord) { 1746 const CFX_ByteStringC& bsDoRecord) {
1749 CFX_ArchiveLoader ArchiveLoader( 1747 CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
1750 reinterpret_cast<const uint8_t*>(bsDoRecord.c_str()),
1751 bsDoRecord.GetLength());
1752 int32_t nType = 0; 1748 int32_t nType = 0;
1753 ArchiveLoader >> nType; 1749 ArchiveLoader >> nType;
1754 ASSERT(nType == FDE_TXTEDT_DORECORD_DEL); 1750 ASSERT(nType == FDE_TXTEDT_DORECORD_DEL);
1755 int32_t nEngine = 0; 1751 int32_t nEngine = 0;
1756 ArchiveLoader >> nEngine; 1752 ArchiveLoader >> nEngine;
1757 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; 1753 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
1758 int32_t iSel = 0; 1754 int32_t iSel = 0;
1759 ArchiveLoader >> iSel; 1755 ArchiveLoader >> iSel;
1760 m_bSel = !!iSel; 1756 m_bSel = !!iSel;
1761 ArchiveLoader >> m_nIndex; 1757 ArchiveLoader >> m_nIndex;
1762 ArchiveLoader >> m_nCaret; 1758 ArchiveLoader >> m_nCaret;
1763 ArchiveLoader >> m_wsRange; 1759 ArchiveLoader >> m_wsRange;
1764 } 1760 }
OLDNEW
« no previous file with comments | « core/fxcrt/include/fx_string.h ('k') | xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698