FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword( const uint8_t* password, FX_DWORD pass_size, FX_BOOL bIgnoreEncryptMeta, uint8_t* key, int32_t key_len) { CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len, bIgnoreEncryptMeta, m_pParser->GetIDArray()); CFX_ByteString ukey = m_pEncryptDict ? m_pEncryptDict->GetString(FX_BSTRC("U")) : CFX_ByteString(); if (ukey.GetLength() < 16) { return FALSE; } uint8_t ukeybuf[32]; if (m_Revision == 2) { FXSYS_memcpy(ukeybuf, defpasscode, 32); CRYPT_ArcFourCryptBlock(ukeybuf, 32, key, key_len); } else { uint8_t test[32], tmpkey[32]; FX_DWORD copy_len = sizeof(test); if (copy_len > (FX_DWORD)ukey.GetLength()) { copy_len = ukey.GetLength(); } FXSYS_memset(test, 0, sizeof(test)); FXSYS_memset(tmpkey, 0, sizeof(tmpkey)); FXSYS_memcpy(test, ukey.c_str(), copy_len); for (int i = 19; i >= 0; i--) { for (int j = 0; j < key_len; j++) { tmpkey[j] = key[j] ^ i; } CRYPT_ArcFourCryptBlock(test, 32, tmpkey, key_len); } uint8_t md5[100]; CRYPT_MD5Start(md5); CRYPT_MD5Update(md5, defpasscode, 32); CPDF_Array* pIdArray = m_pParser->GetIDArray(); if (pIdArray) { CFX_ByteString id = pIdArray->GetString(0); CRYPT_MD5Update(md5, (uint8_t*)id.c_str(), id.GetLength()); } CRYPT_MD5Finish(md5, ukeybuf); return FXSYS_memcmp(test, ukeybuf, 16) == 0; } if (FXSYS_memcmp((void*)ukey.c_str(), ukeybuf, 16) == 0) { return TRUE; } return FALSE; }
static FX_BOOL _CompactStringSame(_CompactString* pCompact, const uint8_t* pStr, int len) { if (len < sizeof(_CompactString)) { if (pCompact->m_CompactLen != len) { return FALSE; } return FXSYS_memcmp(&pCompact->m_LenHigh, pStr, len) == 0; } if (pCompact->m_CompactLen != 0xff || pCompact->m_LenHigh * 256 + pCompact->m_LenLow != len) { return FALSE; } return FXSYS_memcmp(pCompact->m_pBuffer, pStr, len) == 0; }
bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const { if (!m_pData) return str.IsEmpty(); return m_pData->m_nDataLength == str.GetLength() && FXSYS_memcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0; }
FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { if (m_pCS != other.m_pCS || m_pCS == NULL) { return FALSE; } return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; }
bool CFX_ByteString::operator<(const CFX_ByteString& str) const { if (m_pData == str.m_pData) return false; int result = FXSYS_memcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength())); return result < 0 || (result == 0 && GetLength() < str.GetLength()); }
bool CFX_ByteString::operator==(const char* ptr) const { if (!m_pData) return !ptr || !ptr[0]; if (!ptr) return m_pData->m_nDataLength == 0; return FXSYS_strlen(ptr) == m_pData->m_nDataLength && FXSYS_memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; }
CPDF_IccProfile::CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize) : m_bsRGB(FALSE), m_pTransform(NULL), m_nSrcComponents(0) { if (dwSize == 3144 && FXSYS_memcmp(pData + 0x190, "sRGB IEC61966-2.1", 17) == 0) { m_bsRGB = TRUE; m_nSrcComponents = 3; } else if (CPDF_ModuleMgr::Get()->GetIccModule()) { m_pTransform = CPDF_ModuleMgr::Get()->GetIccModule()->CreateTransform_sRGB( pData, dwSize, m_nSrcComponents); } }
FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, FX_BOOL ColorTransform, IFX_JpegProvider* pJP) { if (pJP) { m_pExtProvider = pJP; m_pExtContext = m_pExtProvider->CreateDecoder( src_buf, src_size, width, height, nComps, ColorTransform); return m_pExtContext != NULL; } _JpegScanSOI(src_buf, src_size); m_SrcBuf = src_buf; m_SrcSize = src_size; jerr.error_exit = _error_fatal; jerr.emit_message = _error_do_nothing1; jerr.output_message = _error_do_nothing; jerr.format_message = _error_do_nothing2; jerr.reset_error_mgr = _error_do_nothing; src.init_source = _src_do_nothing; src.term_source = _src_do_nothing; src.skip_input_data = _src_skip_data; src.fill_input_buffer = _src_fill_buffer; src.resync_to_restart = _src_resync; m_bJpegTransform = ColorTransform; if (src_size > 1 && FXSYS_memcmp(src_buf + src_size - 2, "\xFF\xD9", 2) != 0) { ((uint8_t*)src_buf)[src_size - 2] = 0xFF; ((uint8_t*)src_buf)[src_size - 1] = 0xD9; } m_OutputWidth = m_OrigWidth = width; m_OutputHeight = m_OrigHeight = height; if (!InitDecode()) { return FALSE; } if (cinfo.num_components < nComps) { return FALSE; } if ((int)cinfo.image_width < width) { return FALSE; } m_Pitch = (cinfo.image_width * cinfo.num_components + 3) / 4 * 4; m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); m_nComps = cinfo.num_components; m_bpc = 8; m_bColorTransformed = FALSE; m_bStarted = FALSE; return TRUE; }
bool CFX_ByteString::operator==(const CFX_ByteString& other) const { if (m_pData == other.m_pData) return true; if (IsEmpty()) return other.IsEmpty(); if (other.IsEmpty()) return false; return other.m_pData->m_nDataLength == m_pData->m_nDataLength && FXSYS_memcmp(other.m_pData->m_String, m_pData->m_String, m_pData->m_nDataLength) == 0; }
FX_BOOL CPDF_SimpleParser::SearchToken(const CFX_ByteStringC& token) { int token_len = token.GetLength(); while (m_dwCurPos < m_dwSize - token_len) { if (FXSYS_memcmp(m_pData + m_dwCurPos, token.GetPtr(), token_len) == 0) { break; } m_dwCurPos++; } if (m_dwCurPos == m_dwSize - token_len) { return FALSE; } m_dwCurPos += token_len; return TRUE; }
CFieldTree::Node* CFieldTree::Lookup(Node* pParent, const CFX_WideString& short_name) { if (!pParent) return nullptr; for (int i = 0; i < pParent->children.GetSize(); i++) { Node* pNode = pParent->children[i]; if (pNode->short_name.GetLength() == short_name.GetLength() && FXSYS_memcmp(pNode->short_name.c_str(), short_name.c_str(), short_name.GetLength() * sizeof(FX_WCHAR)) == 0) { return pNode; } } return nullptr; }
CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, const CFX_WideString& short_name) { if (pParent == NULL) { return NULL; } CFX_PtrArray& ptr_array = pParent->children; for (int i = 0; i < ptr_array.GetSize(); i++) { _Node* pNode = (_Node*)ptr_array[i]; if (pNode->short_name.GetLength() == short_name.GetLength() && FXSYS_memcmp(pNode->short_name.c_str(), short_name.c_str(), short_name.GetLength() * sizeof(FX_WCHAR)) == 0) { return pNode; } } return NULL; }
FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, uint32_t src_size, int width, int height, int nComps, FX_BOOL ColorTransform) { JpegScanSOI(&src_buf, &src_size); m_SrcBuf = src_buf; m_SrcSize = src_size; jerr.error_exit = _error_fatal; jerr.emit_message = _error_do_nothing1; jerr.output_message = _error_do_nothing; jerr.format_message = _error_do_nothing2; jerr.reset_error_mgr = _error_do_nothing; src.init_source = _src_do_nothing; src.term_source = _src_do_nothing; src.skip_input_data = _src_skip_data; src.fill_input_buffer = _src_fill_buffer; src.resync_to_restart = _src_resync; m_bJpegTransform = ColorTransform; if (src_size > 1 && FXSYS_memcmp(src_buf + src_size - 2, "\xFF\xD9", 2) != 0) { ((uint8_t*)src_buf)[src_size - 2] = 0xFF; ((uint8_t*)src_buf)[src_size - 1] = 0xD9; } m_OutputWidth = m_OrigWidth = width; m_OutputHeight = m_OrigHeight = height; if (!InitDecode()) return FALSE; if (cinfo.num_components < nComps) return FALSE; if ((int)cinfo.image_width < width) return FALSE; m_Pitch = (static_cast<uint32_t>(cinfo.image_width) * cinfo.num_components + 3) / 4 * 4; m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); m_nComps = cinfo.num_components; m_bpc = 8; m_bStarted = FALSE; return TRUE; }
FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, uint32_t size, FX_BOOL bOwner, uint8_t* key) { CFX_ByteString okey = m_pEncryptDict ? m_pEncryptDict->GetStringBy("O") : CFX_ByteString(); if (okey.GetLength() < 48) { return FALSE; } CFX_ByteString ukey = m_pEncryptDict ? m_pEncryptDict->GetStringBy("U") : CFX_ByteString(); if (ukey.GetLength() < 48) { return FALSE; } const uint8_t* pkey = (bOwner ? okey : ukey).raw_str(); uint8_t sha[128]; uint8_t digest[32]; if (m_Revision >= 6) { Revision6_Hash(password, size, (const uint8_t*)pkey + 32, bOwner ? ukey.raw_str() : nullptr, digest); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); CRYPT_SHA256Update(sha, pkey + 32, 8); if (bOwner) { CRYPT_SHA256Update(sha, ukey.raw_str(), 48); } CRYPT_SHA256Finish(sha, digest); } if (FXSYS_memcmp(digest, pkey, 32) != 0) { return FALSE; } if (!key) { return TRUE; } if (m_Revision >= 6) { Revision6_Hash(password, size, (const uint8_t*)pkey + 40, bOwner ? ukey.raw_str() : nullptr, digest); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); CRYPT_SHA256Update(sha, pkey + 40, 8); if (bOwner) { CRYPT_SHA256Update(sha, ukey.raw_str(), 48); } CRYPT_SHA256Finish(sha, digest); } CFX_ByteString ekey = m_pEncryptDict ? m_pEncryptDict->GetStringBy(bOwner ? "OE" : "UE") : CFX_ByteString(); if (ekey.GetLength() < 32) { return FALSE; } uint8_t* aes = FX_Alloc(uint8_t, 2048); CRYPT_AESSetKey(aes, 16, digest, 32, FALSE); uint8_t iv[16]; FXSYS_memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); CRYPT_AESDecrypt(aes, key, ekey.raw_str(), 32); CRYPT_AESSetKey(aes, 16, key, 32, FALSE); CRYPT_AESSetIV(aes, iv); CFX_ByteString perms = m_pEncryptDict->GetStringBy("Perms"); if (perms.IsEmpty()) { return FALSE; } uint8_t perms_buf[16]; FXSYS_memset(perms_buf, 0, sizeof(perms_buf)); uint32_t copy_len = sizeof(perms_buf); if (copy_len > (uint32_t)perms.GetLength()) { copy_len = perms.GetLength(); } FXSYS_memcpy(perms_buf, perms.raw_str(), copy_len); uint8_t buf[16]; CRYPT_AESDecrypt(aes, buf, perms_buf, 16); FX_Free(aes); if (buf[9] != 'a' || buf[10] != 'd' || buf[11] != 'b') { return FALSE; } if (FXDWORD_GET_LSBFIRST(buf) != m_Permissions) { return FALSE; } if ((buf[8] == 'T' && !IsMetadataEncrypted()) || (buf[8] == 'F' && IsMetadataEncrypted())) { return FALSE; } return TRUE; }
FX_BOOL CPDFSDK_DateTime::operator!=(CPDFSDK_DateTime& datetime) { return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0); }
void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR lParam) { switch (msg) { case PNM_NOTEEDITCHANGED: { CPDF_Rect rcScroll = m_pContents->GetScrollArea(); PWL_SCROLL_INFO sInfo; sInfo.fContentMin = rcScroll.bottom; sInfo.fContentMax = rcScroll.top; sInfo.fPlateWidth = m_pContents->GetClientRect().Height(); sInfo.fSmallStep = 13.0f; sInfo.fBigStep = sInfo.fPlateWidth; if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SCROLL_INFO)) != 0) { FX_BOOL bScrollChanged = FALSE; if (lParam < 3) //·ÀÖ¹ËÀÑ»· mantis:15759 { bScrollChanged = ResetScrollBar(); if (bScrollChanged) { lParam++; m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam); } } if (!bScrollChanged) { if (m_pContentsBar->IsVisible()) { m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo); m_OldScrollInfo = sInfo; CPDF_Point ptScroll = m_pContents->GetScrollPos(); CPDF_Point ptOld = ptScroll; if (ptScroll.y > sInfo.fContentMax) ptScroll.y = sInfo.fContentMax; if (ptScroll.y < sInfo.fContentMin + sInfo.fPlateWidth) ptScroll.y = sInfo.fContentMin + sInfo.fPlateWidth; if (ptScroll.y < sInfo.fContentMin) ptScroll.y = sInfo.fContentMin; if (ptOld.y != ptScroll.y) { m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); m_pContentsBar->InvalidateRect(NULL); m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); } } } } } m_pContents->InvalidateRect(NULL); return; case PNM_SCROLLWINDOW: if (m_pContents) m_pContents->OnNotify(pWnd, msg, wParam, lParam); return; case PNM_SETSCROLLPOS: if (m_pContentsBar) m_pContentsBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam); return; } if (msg == PNM_SETCARETINFO && IsValid()) { if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) { if (m_pContents) { CPDF_Rect rcClient = m_pContents->GetClientRect(); if (pInfo->ptHead.y > rcClient.top) { CPDF_Point pt = m_pContents->OutToIn(pInfo->ptHead); m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); CPDF_Point ptScroll = m_pContents->GetScrollPos(); m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); return; } if (pInfo->ptFoot.y < rcClient.bottom) { CPDF_Point pt = m_pContents->OutToIn(pInfo->ptFoot); pt.y += rcClient.Height(); m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); CPDF_Point ptScroll = m_pContents->GetScrollPos(); m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); return; } } } } CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam); }
void IFX_Edit::GenerateRichPageObjects( CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); FX_COLORREF crOld = crCurText; CFX_ByteTextBuf sTextBuf; CPVT_WordProps wp; CPDF_Point ptBT(0.0f, 0.0f); ObjArray.RemoveAll(); if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) { if (pRange) pIterator->SetAt(pRange->BeginPos); else pIterator->SetAt(0); CPVT_WordPlace oldplace; while (pIterator->NextWord()) { CPVT_WordPlace place = pIterator->GetAt(); if (pRange && place.WordCmp(pRange->EndPos) > 0) break; CPVT_Word word; if (pIterator->GetWord(word)) { word.WordProps.fFontSize = word.fFontSize; crCurText = ArgbEncode(255, word.WordProps.dwWordColor); if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || word.WordProps.nHorzScale != 100 || FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || crOld != crCurText) { if (sTextBuf.GetLength() > 0) { ObjArray.Add(AddTextObjToPageObjects( pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.nHorzScale, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), sTextBuf.GetByteString())); sTextBuf.Clear(); } wp = word.WordProps; ptBT = word.ptWord; crOld = crCurText; } sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, word.Word, 0); if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { /* AddLineToPageObjects(pPageObjects, crCurText, CPDF_Point(word.ptWord.x, word.ptWord.y + word.fDescent * 0.4f), CPDF_Point(word.ptWord.x + word.fWidth, word.ptWord.y + word.fDescent * 0.4f)); */ CPDF_Rect rcUnderline = GetUnderLineRect(word); rcUnderline.left += ptOffset.x; rcUnderline.right += ptOffset.x; rcUnderline.top += ptOffset.y; rcUnderline.bottom += ptOffset.y; AddRectToPageObjects(pPageObjects, crCurText, rcUnderline); } if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { CPDF_Rect rcCrossout = GetCrossoutRect(word); rcCrossout.left += ptOffset.x; rcCrossout.right += ptOffset.x; rcCrossout.top += ptOffset.y; rcCrossout.bottom += ptOffset.y; AddRectToPageObjects(pPageObjects, crCurText, rcCrossout); } oldplace = place; } } if (sTextBuf.GetLength() > 0) { ObjArray.Add(AddTextObjToPageObjects( pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.nHorzScale, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), sTextBuf.GetByteString())); } } } }
void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange) { // FX_FLOAT fFontSize = pEdit->GetFontSize(); CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); FX_COLORREF crOld = crCurText; FX_BOOL bSelect = FALSE; const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); CFX_ByteTextBuf sTextBuf; CPVT_WordProps wp; CPDF_Point ptBT(0.0f, 0.0f); pDevice->SaveState(); if (!rcClip.IsEmpty()) { CPDF_Rect rcTemp = rcClip; pUser2Device->TransformRect(rcTemp); FX_RECT rcDevClip; rcDevClip.left = (int32_t)rcTemp.left; rcDevClip.right = (int32_t)rcTemp.right; rcDevClip.top = (int32_t)rcTemp.top; rcDevClip.bottom = (int32_t)rcTemp.bottom; pDevice->SetClip_Rect(&rcDevClip); } if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) { if (pRange) pIterator->SetAt(pRange->BeginPos); else pIterator->SetAt(0); CPVT_WordPlace oldplace; while (pIterator->NextWord()) { CPVT_WordPlace place = pIterator->GetAt(); if (pRange && place.WordCmp(pRange->EndPos) > 0) break; CPVT_Word word; if (pIterator->GetWord(word)) { word.WordProps.fFontSize = word.fFontSize; crCurText = ArgbEncode(255, word.WordProps.dwWordColor); if (wrSelect.IsExist()) { bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && place.WordCmp(wrSelect.EndPos) <= 0; if (bSelect) { crCurText = crWhite; } } if (bSelect) { CPVT_Line line; pIterator->GetLine(line); CFX_PathData pathSelBK; pathSelBK.AppendRect(word.ptWord.x + ptOffset.x, line.ptLine.y + line.fLineDescent + ptOffset.y, word.ptWord.x + word.fWidth + ptOffset.x, line.ptLine.y + line.fLineAscent + ptOffset.y); pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, FXFILL_WINDING); } if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || word.WordProps.nHorzScale != 100 || FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || crOld != crCurText) { if (sTextBuf.GetLength() > 0) { DrawTextString( pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale); sTextBuf.Clear(); } wp = word.WordProps; ptBT = word.ptWord; crOld = crCurText; } sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, word.Word, 0); if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { CFX_PathData pathUnderline; CPDF_Rect rcUnderline = GetUnderLineRect(word); pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, rcUnderline.right, rcUnderline.top); pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0, FXFILL_WINDING); } if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { CFX_PathData pathCrossout; CPDF_Rect rcCrossout = GetCrossoutRect(word); pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom, rcCrossout.right, rcCrossout.top); pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0, FXFILL_WINDING); } oldplace = place; } } if (sTextBuf.GetLength() > 0) { DrawTextString( pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale); } } } pDevice->RestoreState(); }
static void _png_load_bmp_attribute(png_structp png_ptr, png_infop info_ptr, CFX_DIBAttribute* pAttribute) { if (pAttribute) { #if defined(PNG_pHYs_SUPPORTED) pAttribute->m_nXDPI = png_get_x_pixels_per_meter(png_ptr, info_ptr); pAttribute->m_nYDPI = png_get_y_pixels_per_meter(png_ptr, info_ptr); png_uint_32 res_x, res_y; int unit_type; png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); switch (unit_type) { case PNG_RESOLUTION_METER: pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER; break; default: pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_NONE; } #endif #if defined(PNG_iCCP_SUPPORTED) png_charp icc_name; png_bytep icc_profile; png_uint_32 icc_proflen; int compress_type; png_get_iCCP(png_ptr, info_ptr, &icc_name, &compress_type, &icc_profile, &icc_proflen); #endif int bTime = 0; #if defined(PNG_tIME_SUPPORTED) png_timep t = nullptr; png_get_tIME(png_ptr, info_ptr, &t); if (t) { FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); FXSYS_snprintf((FX_CHAR*)pAttribute->m_strTime, sizeof(pAttribute->m_strTime), "%4u:%2u:%2u %2u:%2u:%2u", t->year, t->month, t->day, t->hour, t->minute, t->second); pAttribute->m_strTime[sizeof(pAttribute->m_strTime) - 1] = 0; bTime = 1; } #endif #if defined(PNG_TEXT_SUPPORTED) int i; FX_STRSIZE len; const FX_CHAR* buf; int num_text; png_textp text = nullptr; png_get_text(png_ptr, info_ptr, &text, &num_text); for (i = 0; i < num_text; i++) { len = FXSYS_strlen(text[i].key); buf = "Time"; if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) { if (!bTime) { FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); FXSYS_memcpy( pAttribute->m_strTime, text[i].text, std::min(sizeof(pAttribute->m_strTime) - 1, text[i].text_length)); } } else { buf = "Author"; if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) { pAttribute->m_strAuthor = CFX_ByteString(reinterpret_cast<uint8_t*>(text[i].text), static_cast<FX_STRSIZE>(text[i].text_length)); } } } #endif } }
void CFX_SAXReader::SkipNode() { int32_t iLen = m_SkipStack.GetSize(); if (m_SkipChar == '\'' || m_SkipChar == '\"') { if (m_CurByte != m_SkipChar) { return; } iLen--; FXSYS_assert(iLen > -1); m_SkipStack.RemoveAt(iLen, 1); m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0; return; } switch (m_CurByte) { case '<': m_SkipChar = '>'; m_SkipStack.Add('>'); break; case '[': m_SkipChar = ']'; m_SkipStack.Add(']'); break; case '(': m_SkipChar = ')'; m_SkipStack.Add(')'); break; case '\'': m_SkipChar = '\''; m_SkipStack.Add('\''); break; case '\"': m_SkipChar = '\"'; m_SkipStack.Add('\"'); break; default: if (m_CurByte == m_SkipChar) { iLen--; m_SkipStack.RemoveAt(iLen, 1); m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0; if (iLen == 0 && m_CurByte == '>') { m_iDataLength = m_iDataPos; m_iDataPos = 0; if (m_iDataLength >= 9 && FXSYS_memcmp(m_pszData, "[CDATA[", 7 * sizeof(uint8_t)) == 0 && FXSYS_memcmp(m_pszData + m_iDataLength - 2, "]]", 2 * sizeof(uint8_t)) == 0) { Pop(); m_iDataLength -= 9; m_dwDataOffset += 7; FXSYS_memmove(m_pszData, m_pszData + 7, m_iDataLength * sizeof(uint8_t)); m_bCharData = TRUE; if (m_pHandler) { NotifyData(); } m_bCharData = FALSE; } else { Pop(); } m_eMode = FX_SAXMODE_Text; } } break; } if (iLen > 0) { ParseChar(m_CurByte); } }
FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const { if (!m_pDict) return !pOther->m_pDict; if (!m_pDict->Identical(pOther->m_pDict)) return FALSE; if (m_dwSize != pOther->m_dwSize) return FALSE; if (!IsMemoryBased() && !pOther->IsMemoryBased()) { if (m_pFile == pOther->m_pFile && !m_pFile) return TRUE; if (!m_pFile || !pOther->m_pFile) return FALSE; uint8_t srcBuf[kBlockSize]; uint8_t destBuf[kBlockSize]; FX_DWORD size = m_dwSize; if (m_pFile == pOther->m_pFile) return TRUE; FX_DWORD offset = 0; while (size > 0) { FX_DWORD actualSize = std::min(size, kBlockSize); m_pFile->ReadBlock(srcBuf, offset, actualSize); pOther->m_pFile->ReadBlock(destBuf, offset, actualSize); if (FXSYS_memcmp(srcBuf, destBuf, actualSize) != 0) return FALSE; size -= actualSize; offset += actualSize; } return TRUE; } if (!IsMemoryBased() || !pOther->IsMemoryBased()) { IFX_FileRead* pFile = nullptr; uint8_t* pBuf = nullptr; if (!pOther->IsMemoryBased()) { pFile = pOther->m_pFile; pBuf = m_pDataBuf; } else if (!IsMemoryBased()) { pFile = m_pFile; pBuf = pOther->m_pDataBuf; } if (!pBuf) return FALSE; uint8_t srcBuf[kBlockSize]; FX_DWORD size = m_dwSize; FX_DWORD offset = 0; while (size > 0) { FX_DWORD actualSize = std::min(size, kBlockSize); pFile->ReadBlock(srcBuf, offset, actualSize); if (FXSYS_memcmp(srcBuf, pBuf, actualSize) != 0) return FALSE; pBuf += actualSize; size -= actualSize; offset += actualSize; } return TRUE; } return FXSYS_memcmp(m_pDataBuf, pOther->m_pDataBuf, m_dwSize) == 0; }
FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const { if (!m_pDict) return pOther->m_pDict ? FALSE : TRUE; if (!m_pDict->Identical(pOther->m_pDict)) { return FALSE; } if (m_dwSize != pOther->m_dwSize) { return FALSE; } if (m_GenNum != (FX_DWORD) - 1 && pOther->m_GenNum != (FX_DWORD) - 1) { if (m_pFile == pOther->m_pFile && m_pFile == NULL) { return TRUE; } if (!m_pFile || !pOther->m_pFile) { return FALSE; } uint8_t srcBuf[1024]; uint8_t destBuf[1024]; FX_DWORD size = m_dwSize; FX_DWORD srcOffset = m_FileOffset; FX_DWORD destOffset = pOther->m_FileOffset; if (m_pFile == pOther->m_pFile && srcOffset == destOffset) { return TRUE; } while (size > 0) { FX_DWORD actualSize = size > 1024 ? 1024 : size; m_pFile->ReadBlock(srcBuf, srcOffset, actualSize); pOther->m_pFile->ReadBlock(destBuf, destOffset, actualSize); if (FXSYS_memcmp(srcBuf, destBuf, actualSize) != 0) { return FALSE; } size -= actualSize; srcOffset += actualSize; destOffset += actualSize; } return TRUE; } if (m_GenNum != (FX_DWORD) - 1 || pOther->m_GenNum != (FX_DWORD) - 1) { IFX_FileRead* pFile = NULL; uint8_t* pBuf = NULL; FX_DWORD offset = 0; if (pOther->m_GenNum != (FX_DWORD) - 1) { pFile = pOther->m_pFile; pBuf = m_pDataBuf; offset = pOther->m_FileOffset; } else if (m_GenNum != (FX_DWORD) - 1) { pFile = m_pFile; pBuf = pOther->m_pDataBuf; offset = m_FileOffset; } if (NULL == pBuf) { return FALSE; } uint8_t srcBuf[1024]; FX_DWORD size = m_dwSize; while (size > 0) { FX_DWORD actualSize = std::min(size, 1024U); pFile->ReadBlock(srcBuf, offset, actualSize); if (FXSYS_memcmp(srcBuf, pBuf, actualSize) != 0) { return FALSE; } pBuf += actualSize; size -= actualSize; offset += actualSize; } return TRUE; } return FXSYS_memcmp(m_pDataBuf, pOther->m_pDataBuf, m_dwSize) == 0; }
FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { return m_pCS && m_pCS == other.m_pCS && FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; }