bool CPDF_InterForm::ValidateFieldName( CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl) const { if (csNewFieldName.IsEmpty()) return false; int iPos = 0; int iLength = csNewFieldName.GetLength(); CFX_WideString csSub; while (true) { while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName[iPos] == L' ')) { iPos++; } if (iPos < iLength && !csSub.IsEmpty()) csSub += L'.'; while (iPos < iLength && csNewFieldName[iPos] != L'.') csSub += csNewFieldName[iPos++]; for (int i = csSub.GetLength() - 1; i > -1; i--) { if (csSub[i] != L' ' && csSub[i] != L'.') break; csSub.SetAt(i, L'\0'); } size_t dwCount = m_pFieldTree->m_Root.CountFields(); for (size_t m = 0; m < dwCount; ++m) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(m); if (!pField) continue; if (pField == pExcludedField) { if (!pExcludedControl || pField->CountControls() < 2) continue; } CFX_WideString csFullName = pField->GetFullName(); int iRet = CompareFieldName(csSub, csFullName); if (iRet == 1) { if (pField->GetFieldType() != iType) return false; } else if (iRet == 2 && csSub == csNewFieldName) { if (csFullName[iPos] == L'.') return false; } else if (iRet == 3 && csSub == csNewFieldName) { if (csNewFieldName[csFullName.GetLength()] == L'.') return false; } } if (iPos >= iLength) break; } if (csSub.IsEmpty()) return false; csNewFieldName = csSub; return true; }
void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { CFX_WideString buffer; buffer += (FX_WCHAR)'\0'; while (context.hasMoreCharacters()) { FX_WCHAR c = context.getCurrentChar(); buffer += c; context.m_pos++; int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( context.m_msg, context.m_pos, getEncodingMode()); if (newMode != getEncodingMode()) { context.signalEncoderChange(newMode); break; } } int32_t dataCount = buffer.GetLength() - 1; FX_CHAR buf[128]; FXSYS_itoa(dataCount, buf, 10); buffer.SetAt(0, FX_WCHAR(*buf) - '0'); int32_t lengthFieldSize = 1; int32_t currentSize = context.getCodewordCount() + dataCount + lengthFieldSize; context.updateSymbolInfo(currentSize, e); if (e != BCExceptionNO) { return; } FX_BOOL mustPad = (context.m_symbolInfo->m_dataCapacity - currentSize) > 0; if (context.hasMoreCharacters() || mustPad) { if (dataCount <= 249) { buffer.SetAt(0, (FX_WCHAR)dataCount); } else if (dataCount > 249 && dataCount <= 1555) { buffer.SetAt(0, (FX_WCHAR)((dataCount / 250) + 249)); buffer.Insert(1, (FX_WCHAR)(dataCount % 250)); } else { e = BCExceptionIllegalStateMessageLengthInvalid; return; } } for (int32_t i = 0, c = buffer.GetLength(); i < c; i++) { context.writeCodeword( randomize255State(buffer.GetAt(i), context.getCodewordCount() + 1)); } }
CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, CBC_SymbolInfo* symbolInfo, int32_t& e) { if (codewords.GetLength() != symbolInfo->m_dataCapacity) { e = BCExceptionIllegalArgument; return (FX_WCHAR*)""; } CFX_WideString sb; sb += codewords; int32_t blockCount = symbolInfo->getInterleavedBlockCount(); if (blockCount == 1) { CFX_WideString ecc = createECCBlock(codewords, symbolInfo->m_errorCodewords, e); BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); sb += ecc; } else { CFX_Int32Array dataSizes; dataSizes.SetSize(blockCount); CFX_Int32Array errorSizes; errorSizes.SetSize(blockCount); CFX_Int32Array startPos; startPos.SetSize(blockCount); for (int32_t i = 0; i < blockCount; i++) { dataSizes[i] = symbolInfo->getDataLengthForInterleavedBlock(i + 1); errorSizes[i] = symbolInfo->getErrorLengthForInterleavedBlock(i + 1); startPos[i] = 0; if (i > 0) { startPos[i] = startPos[i - 1] + dataSizes[i]; } } for (int32_t block = 0; block < blockCount; block++) { CFX_WideString temp; for (int32_t d = block; d < symbolInfo->m_dataCapacity; d += blockCount) { temp += (FX_WCHAR)codewords.GetAt(d); } CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e); BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); int32_t pos = 0; for (int32_t l = block; l < errorSizes[block] * blockCount; l += blockCount) { sb.SetAt(symbolInfo->m_dataCapacity + l, ecc.GetAt(pos++)); } } } return sb; }
FX_BOOL CPDF_InterForm::ValidateFieldName( CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl) { if (csNewFieldName.IsEmpty()) { return FALSE; } int iPos = 0; int iLength = csNewFieldName.GetLength(); CFX_WideString csSub; while (TRUE) { while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName[iPos] == L' ')) { iPos++; } if (iPos < iLength && !csSub.IsEmpty()) { csSub += L'.'; } while (iPos < iLength && csNewFieldName[iPos] != L'.') { csSub += csNewFieldName[iPos++]; } for (int i = csSub.GetLength() - 1; i > -1; i--) { if (csSub[i] == L' ' || csSub[i] == L'.') { csSub.SetAt(i, L'\0'); } else { break; } } FX_DWORD dwCount = m_pFieldTree->m_Root.CountFields(); for (FX_DWORD m = 0; m < dwCount; m++) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(m); if (pField == NULL) { continue; } if (pField == pExcludedField) { if (pExcludedControl != NULL) { if (pField->CountControls() < 2) { continue; } } else { continue; } } CFX_WideString csFullName = pField->GetFullName(); int iRet = CompareFieldName(csSub, csFullName); if (iRet == 1) { if (pField->GetFieldType() != iType) { return FALSE; } } else if (iRet == 2 && csSub == csNewFieldName) { if (csFullName[iPos] == L'.') { return FALSE; } } else if (iRet == 3 && csSub == csNewFieldName) { if (csNewFieldName[csFullName.GetLength()] == L'.') { return FALSE; } } } if (iPos >= iLength) { break; } } if (csSub.IsEmpty()) { return FALSE; } csNewFieldName = csSub; return TRUE; }