本文整理汇总了C++中CFX_WideString::ReleaseBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CFX_WideString::ReleaseBuffer方法的具体用法?C++ CFX_WideString::ReleaseBuffer怎么用?C++ CFX_WideString::ReleaseBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFX_WideString
的用法示例。
在下文中一共展示了CFX_WideString::ReleaseBuffer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CutString
CFX_WideString Document::CutString(CFX_WideString cbFrom)
{
size_t iLength = cbFrom.GetLength();
pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
iSize *= (iLength + 1);
wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
for (int i = 0; i < iLength; i++)
{
if (pFrom[i] == L'\\' || pFrom[i] == L'/')
{
pResult[i] = L'\0';
break;
}
pResult[i] = pFrom[i];
}
pResult[iLength] = L'\0';
cbFrom.ReleaseBuffer();
CFX_WideString cbRet = CFX_WideString(pResult);
free(pResult);
pResult = NULL;
return cbRet;
}
示例2: GetRange
void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
int32_t nBegin,
int32_t nLength) const {
FDE_CHUNKPLACE cp;
Index2CP(nBegin, cp);
int32_t nLeave = nLength;
int32_t nCount = m_Chunks.GetSize();
FX_WCHAR* lpDstBuf = wsText.GetBuffer(nLength);
int32_t nChunkIndex = cp.nChunkIndex;
FDE_CHUNKHEADER* lpChunkHeader = m_Chunks[nChunkIndex];
int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex;
FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex;
while (nLeave > 0) {
if (nLeave <= nCopyLength) {
nCopyLength = nLeave;
}
FXSYS_memcpy(lpDstBuf, lpSrcBuf, nCopyLength * sizeof(FX_WCHAR));
nChunkIndex++;
if (nChunkIndex >= nCount) {
break;
}
lpChunkHeader = m_Chunks[nChunkIndex];
lpSrcBuf = lpChunkHeader->wChars;
nLeave -= nCopyLength;
lpDstBuf += nCopyLength;
nCopyLength = lpChunkHeader->nUsed;
}
wsText.ReleaseBuffer();
}
示例3: ExtractSubString
FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
const FX_WCHAR* lpszFullString,
int iSubString,
FX_WCHAR chSep) {
if (!lpszFullString)
return FALSE;
while (iSubString--) {
lpszFullString = std::wcschr(lpszFullString, chSep);
if (!lpszFullString) {
rString.clear();
return FALSE;
}
lpszFullString++;
while (*lpszFullString == chSep)
lpszFullString++;
}
const FX_WCHAR* lpchEnd = std::wcschr(lpszFullString, chSep);
int nLen = lpchEnd ? (int)(lpchEnd - lpszFullString)
: (int)FXSYS_wcslen(lpszFullString);
ASSERT(nLen >= 0);
FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString,
nLen * sizeof(FX_WCHAR));
rString.ReleaseBuffer();
return TRUE;
}
示例4: GetString
int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece,
CFX_WideString& wsText) {
FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount);
for (int32_t i = 0; i < pPiece->nCount; i++) {
pBuffer[i] = m_pPage->GetChar(pPiece, i);
}
wsText.ReleaseBuffer(pPiece->nCount);
return pPiece->nCount;
}
示例5: FX_WideString_GetNormalization
FX_STRSIZE FX_WideString_GetNormalization(const CFX_WideStringC& wsSrc,
CFX_WideString& wsDst) {
FX_STRSIZE nLen = FX_WideString_GetNormalization(wsSrc, (FX_WCHAR*)NULL);
if (!nLen) {
return 0;
}
FX_WCHAR* pBuf = wsDst.GetBuffer(nLen);
FX_WideString_GetNormalization(wsSrc, pBuf);
wsDst.ReleaseBuffer(nLen);
return nLen;
}
示例6: CFX_WideString
CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, FX_STRSIZE wlen)
{
if (!wstr || 0 == wlen) {
return CFX_WideString();
}
CFX_WideString result;
FX_WCHAR* buf = result.GetBuffer(wlen);
for (int i = 0; i < wlen; i ++) {
buf[i] = wstr[i];
}
result.ReleaseBuffer(wlen);
return result;
}
示例7: SetText
void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
ResetEngine();
int32_t nLength = wsText.GetLength();
if (nLength > 0) {
CFX_WideString wsTemp;
FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength);
FXSYS_memcpy(lpBuffer, wsText.c_str(), nLength * sizeof(FX_WCHAR));
ReplaceParagEnd(lpBuffer, nLength, FALSE);
wsTemp.ReleaseBuffer(nLength);
if (m_nLimit > 0 && nLength > m_nLimit) {
wsTemp.Delete(m_nLimit, nLength - m_nLimit);
nLength = m_nLimit;
}
m_pTxtBuf->SetText(wsTemp);
}
m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1);
RebuildParagraphs();
}
示例8: RecoverParagEnd
void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r';
if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) {
CFX_ArrayTemplate<int32_t> PosArr;
int32_t nLength = wsText.GetLength();
int32_t i = 0;
FX_WCHAR* lpPos = const_cast<FX_WCHAR*>(wsText.c_str());
for (i = 0; i < nLength; i++, lpPos++) {
if (*lpPos == m_wLineEnd) {
*lpPos = wc;
PosArr.Add(i);
}
}
const FX_WCHAR* lpSrcBuf = wsText.c_str();
CFX_WideString wsTemp;
int32_t nCount = PosArr.GetSize();
FX_WCHAR* lpDstBuf = wsTemp.GetBuffer(nLength + nCount);
int32_t nDstPos = 0;
int32_t nSrcPos = 0;
for (i = 0; i < nCount; i++) {
int32_t nPos = PosArr[i];
int32_t nCopyLen = nPos - nSrcPos + 1;
FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos,
nCopyLen * sizeof(FX_WCHAR));
nDstPos += nCopyLen;
nSrcPos += nCopyLen;
lpDstBuf[nDstPos] = L'\n';
nDstPos++;
}
if (nSrcPos < nLength) {
FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos,
(nLength - nSrcPos) * sizeof(FX_WCHAR));
}
wsTemp.ReleaseBuffer(nLength + nCount);
wsText = wsTemp;
} else {
int32_t nLength = wsText.GetLength();
FX_WCHAR* lpBuf = const_cast<FX_WCHAR*>(wsText.c_str());
for (int32_t i = 0; i < nLength; i++, lpBuf++) {
if (*lpBuf == m_wLineEnd)
*lpBuf = wc;
}
}
}
示例9: GetTitle
CFX_WideString CPDF_Bookmark::GetTitle()
{
if (!m_pDict) {
return CFX_WideString();
}
CPDF_String* pString = (CPDF_String*)m_pDict->GetElementValue("Title");
if (pString == NULL || pString->GetType() != PDFOBJ_STRING) {
return CFX_WideString();
}
CFX_WideString title = pString->GetUnicodeText();
FX_LPWSTR buf = title.LockBuffer();
int len = title.GetLength(), i;
for (i = 0; i < len; i ++)
if (buf[i] < 0x20) {
buf[i] = 0x20;
}
title.ReleaseBuffer(len);
return title;
}
示例10: ReversalStr
CFX_WideString Document::ReversalStr(CFX_WideString cbFrom)
{
size_t iLength = cbFrom.GetLength();
pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
iSize *= (iLength + 1);
wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
for (size_t i = 0; i < iLength; i++)
{
pResult[i] = *(pFrom + iLength - i - 1);
}
pResult[iLength] = L'\0';
cbFrom.ReleaseBuffer();
CFX_WideString cbRet = CFX_WideString(pResult);
free(pResult);
pResult = NULL;
return cbRet;
}
示例11: while
static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression,
int32_t nStart,
CFX_WideString& wsFilter) {
FXSYS_assert(nStart > -1);
int32_t iLength = wsExpression.GetLength();
if (nStart >= iLength) {
return iLength;
}
FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart);
int32_t nCount = 0;
const FX_WCHAR* pSrc = wsExpression.GetPtr();
FX_WCHAR wCur;
while (nStart < iLength) {
wCur = pSrc[nStart++];
if (wCur == ',') {
break;
}
pBuf[nCount++] = wCur;
}
wsFilter.ReleaseBuffer(nCount);
wsFilter.TrimLeft();
wsFilter.TrimRight();
return nStart;
}
示例12: GetPreInsertText
void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText,
int32_t nIndex,
const FX_WCHAR* lpText,
int32_t nLength) {
GetText(wsText, 0, GetTextBufLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
int32_t nSelCount = CountSelRanges();
while (nSelCount--) {
nSelLength = GetSelRange(nSelCount, nSelIndex);
wsText.Delete(nSelIndex, nSelLength);
nIndex = nSelIndex;
}
CFX_WideString wsTemp;
int32_t nOldLength = wsText.GetLength();
const FX_WCHAR* pOldBuffer = wsText.c_str();
FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nOldLength + nLength);
FXSYS_memcpy(lpBuffer, pOldBuffer, (nIndex) * sizeof(FX_WCHAR));
FXSYS_memcpy(lpBuffer + nIndex, lpText, nLength * sizeof(FX_WCHAR));
FXSYS_memcpy(lpBuffer + nIndex + nLength, pOldBuffer + nIndex,
(nOldLength - nIndex) * sizeof(FX_WCHAR));
wsTemp.ReleaseBuffer(nOldLength + nLength);
wsText = wsTemp;
}
示例13: GetNumbericFormat
void CXFA_LocaleValue::GetNumbericFormat(CFX_WideString& wsFormat,
int32_t nIntLen,
int32_t nDecLen,
FX_BOOL bSign) {
ASSERT(wsFormat.IsEmpty());
ASSERT(nIntLen >= -1 && nDecLen >= -1);
int32_t nTotalLen = (nIntLen >= 0 ? nIntLen : 2) + (bSign ? 1 : 0) +
(nDecLen >= 0 ? nDecLen : 2) + (nDecLen == 0 ? 0 : 1);
FX_WCHAR* lpBuf = wsFormat.GetBuffer(nTotalLen);
int32_t nPos = 0;
if (bSign) {
lpBuf[nPos++] = L's';
}
if (nIntLen == -1) {
lpBuf[nPos++] = L'z';
lpBuf[nPos++] = L'*';
} else {
while (nIntLen) {
lpBuf[nPos++] = L'z';
nIntLen--;
}
}
if (nDecLen != 0) {
lpBuf[nPos++] = L'.';
}
if (nDecLen == -1) {
lpBuf[nPos++] = L'z';
lpBuf[nPos++] = L'*';
} else {
while (nDecLen) {
lpBuf[nPos++] = L'z';
nDecLen--;
}
}
wsFormat.ReleaseBuffer(nTotalLen);
}
示例14: Insert
int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
const FX_WCHAR* lpText,
int32_t nLength) {
if (IsLocked()) {
return FDE_TXTEDT_MODIFY_RET_F_Locked;
}
CFX_WideString wsTemp;
FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength);
FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR));
ReplaceParagEnd(lpBuffer, nLength, FALSE);
wsTemp.ReleaseBuffer(nLength);
FX_BOOL bPart = FALSE;
if (m_nLimit > 0) {
int32_t nTotalLength = GetTextBufLength();
int32_t nCount = m_SelRangePtrArr.GetSize();
for (int32_t i = 0; i < nCount; i++) {
FDE_TXTEDTSELRANGE* lpSelRange = m_SelRangePtrArr.GetAt(i);
nTotalLength -= lpSelRange->nCount;
}
int32_t nExpectLength = nTotalLength + nLength;
if (nTotalLength == m_nLimit) {
return FDE_TXTEDT_MODIFY_RET_F_Full;
}
if (nExpectLength > m_nLimit) {
nLength -= (nExpectLength - m_nLimit);
bPart = TRUE;
}
}
if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) ||
(m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) {
int32_t nTemp = nLength;
if (m_Param.dwMode & FDE_TEXTEDITMODE_Password) {
CFX_WideString wsText;
while (nLength > 0) {
GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength);
int32_t nTotal = wsText.GetLength();
FX_WCHAR* lpBuf = wsText.GetBuffer(nTotal);
for (int32_t i = 0; i < nTotal; i++) {
lpBuf[i] = m_wcAliasChar;
}
wsText.ReleaseBuffer(nTotal);
if (IsFitArea(wsText)) {
break;
}
nLength--;
}
} else {
CFX_WideString wsText;
while (nLength > 0) {
GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength);
if (IsFitArea(wsText)) {
break;
}
nLength--;
}
}
if (nLength == 0) {
return FDE_TXTEDT_MODIFY_RET_F_Full;
}
if (nLength < nTemp) {
bPart = TRUE;
}
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
CFX_WideString wsText;
GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength);
if (!m_Param.pEventSink->On_Validate(this, wsText)) {
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
}
}
if (IsSelect()) {
DeleteSelect();
}
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;
m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength);
nStart = m_nCaret;
nStart += nLength;
FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1);
FX_BOOL bBefore = TRUE;
if (wChar != L'\n' && wChar != L'\r') {
nStart--;
bBefore = FALSE;
}
SetCaretPos(nStart, bBefore);
m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal;
}