本文整理汇总了C++中CPDF_Array类的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Array类的具体用法?C++ CPDF_Array怎么用?C++ CPDF_Array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPDF_Array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) {
int32_t width;
int32_t height;
int32_t num_comps;
int32_t bits;
FX_BOOL color_trans;
if (!CPDF_ModuleMgr::Get()->GetJpegModule()->LoadInfo(
pData, size, width, height, num_comps, bits, color_trans)) {
return NULL;
}
CPDF_Dictionary* pDict = new CPDF_Dictionary;
pDict->SetAtName("Type", "XObject");
pDict->SetAtName("Subtype", "Image");
pDict->SetAtInteger("Width", width);
pDict->SetAtInteger("Height", height);
const FX_CHAR* csname = NULL;
if (num_comps == 1) {
csname = "DeviceGray";
} else if (num_comps == 3) {
csname = "DeviceRGB";
} else if (num_comps == 4) {
csname = "DeviceCMYK";
CPDF_Array* pDecode = CPDF_Array::Create();
for (int n = 0; n < 4; n++) {
pDecode->AddInteger(1);
pDecode->AddInteger(0);
}
pDict->SetAt(FX_BSTRC("Decode"), pDecode);
}
pDict->SetAtName("ColorSpace", csname);
pDict->SetAtInteger("BitsPerComponent", bits);
pDict->SetAtName("Filter", "DCTDecode");
if (!color_trans) {
CPDF_Dictionary* pParms = new CPDF_Dictionary;
pDict->SetAt("DecodeParms", pParms);
pParms->SetAtInteger("ColorTransform", 0);
}
m_bIsMask = FALSE;
m_Width = width;
m_Height = height;
if (m_pStream == NULL) {
m_pStream = new CPDF_Stream(NULL, 0, NULL);
}
return pDict;
}
示例2: GetColor
FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
const CFX_ByteStringC& csEntry) {
iColorType = COLORTYPE_TRANSPARENT;
if (m_pDict == NULL) {
return 0;
}
FX_ARGB color = 0;
CPDF_Array* pEntry = m_pDict->GetArray(csEntry);
if (pEntry == NULL) {
return color;
}
FX_DWORD dwCount = pEntry->GetCount();
if (dwCount == 1) {
iColorType = COLORTYPE_GRAY;
FX_FLOAT g = pEntry->GetNumber(0) * 255;
color = ArgbEncode(255, (int)g, (int)g, (int)g);
} else if (dwCount == 3) {
iColorType = COLORTYPE_RGB;
FX_FLOAT r = pEntry->GetNumber(0) * 255;
FX_FLOAT g = pEntry->GetNumber(1) * 255;
FX_FLOAT b = pEntry->GetNumber(2) * 255;
color = ArgbEncode(255, (int)r, (int)g, (int)b);
} else if (dwCount == 4) {
iColorType = COLORTYPE_CMYK;
FX_FLOAT c = pEntry->GetNumber(0);
FX_FLOAT m = pEntry->GetNumber(1);
FX_FLOAT y = pEntry->GetNumber(2);
FX_FLOAT k = pEntry->GetNumber(3);
FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k);
FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k);
FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k);
color = ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255));
}
return color;
}
示例3: if
void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict)
{
m_pPage = pPageDict;
if (m_pTreeRoot == NULL) {
return;
}
CPDF_Object* pKids = m_pTreeRoot->GetElementValue(FX_BSTRC("K"));
if (pKids == NULL) {
return;
}
FX_DWORD dwKids = 0;
if (pKids->GetType() == PDFOBJ_DICTIONARY) {
dwKids = 1;
} else if (pKids->GetType() == PDFOBJ_ARRAY) {
dwKids = ((CPDF_Array*)pKids)->GetCount();
} else {
return;
}
FX_DWORD i;
m_Kids.SetSize(dwKids);
for (i = 0; i < dwKids; i ++) {
m_Kids[i] = NULL;
}
CFX_MapPtrToPtr element_map;
CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDict(FX_BSTRC("ParentTree"));
if (pParentTree == NULL) {
return;
}
CPDF_NumberTree parent_tree(pParentTree);
int parents_id = pPageDict->GetInteger(FX_BSTRC("StructParents"), -1);
if (parents_id >= 0) {
CPDF_Object* pParents = parent_tree.LookupValue(parents_id);
if (pParents == NULL || pParents->GetType() != PDFOBJ_ARRAY) {
return;
}
CPDF_Array* pParentArray = (CPDF_Array*)pParents;
for (i = 0; i < pParentArray->GetCount(); i ++) {
CPDF_Dictionary* pParent = pParentArray->GetDict(i);
if (pParent == NULL) {
continue;
}
AddPageNode(pParent, element_map);
}
}
}
示例4: LoadPDFEncoding
FX_BOOL CPDF_Type3Font::Load() {
m_pFontResources = m_pFontDict->GetDictBy("Resources");
CPDF_Array* pMatrix = m_pFontDict->GetArrayBy("FontMatrix");
FX_FLOAT xscale = 1.0f, yscale = 1.0f;
if (pMatrix) {
m_FontMatrix = pMatrix->GetMatrix();
xscale = m_FontMatrix.a;
yscale = m_FontMatrix.d;
}
CPDF_Array* pBBox = m_pFontDict->GetArrayBy("FontBBox");
if (pBBox) {
m_FontBBox.left = (int32_t)(pBBox->GetNumberAt(0) * xscale * 1000);
m_FontBBox.bottom = (int32_t)(pBBox->GetNumberAt(1) * yscale * 1000);
m_FontBBox.right = (int32_t)(pBBox->GetNumberAt(2) * xscale * 1000);
m_FontBBox.top = (int32_t)(pBBox->GetNumberAt(3) * yscale * 1000);
}
int StartChar = m_pFontDict->GetIntegerBy("FirstChar");
CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths");
if (pWidthArray && (StartChar >= 0 && StartChar < 256)) {
size_t count = pWidthArray->GetCount();
if (count > 256)
count = 256;
if (StartChar + count > 256)
count = 256 - StartChar;
for (size_t i = 0; i < count; i++) {
m_CharWidthL[StartChar + i] =
FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000);
}
}
m_pCharProcs = m_pFontDict->GetDictBy("CharProcs");
CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding");
if (pEncoding) {
LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, FALSE, FALSE);
if (!m_CharNames.empty()) {
for (int i = 0; i < 256; i++) {
m_Encoding.m_Unicodes[i] =
PDF_UnicodeFromAdobeName(m_CharNames[i].c_str());
if (m_Encoding.m_Unicodes[i] == 0) {
m_Encoding.m_Unicodes[i] = i;
}
}
}
}
return TRUE;
}
示例5: GetOriginalColor
void CPDF_ApSettings::GetOriginalColor(int& iColorType,
FX_FLOAT fc[4],
const CFX_ByteStringC& csEntry) const {
iColorType = COLORTYPE_TRANSPARENT;
for (int i = 0; i < 4; i++) {
fc[i] = 0;
}
if (!m_pDict) {
return;
}
CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
if (!pEntry) {
return;
}
FX_DWORD dwCount = pEntry->GetCount();
if (dwCount == 1) {
iColorType = COLORTYPE_GRAY;
fc[0] = pEntry->GetNumberAt(0);
} else if (dwCount == 3) {
iColorType = COLORTYPE_RGB;
fc[0] = pEntry->GetNumberAt(0);
fc[1] = pEntry->GetNumberAt(1);
fc[2] = pEntry->GetNumberAt(2);
} else if (dwCount == 4) {
iColorType = COLORTYPE_CMYK;
fc[0] = pEntry->GetNumberAt(0);
fc[1] = pEntry->GetNumberAt(1);
fc[2] = pEntry->GetNumberAt(2);
fc[3] = pEntry->GetNumberAt(3);
}
}
示例6: PDF_ReplaceFull
void PDF_ReplaceFull(CPDF_Object* pObj) {
switch (pObj->GetType()) {
case PDFOBJ_DICTIONARY: {
CPDF_Dictionary* pDict = pObj->AsDictionary();
for (const auto& it : *pDict) {
CFX_ByteString key = it.first;
CPDF_Object* value = it.second;
CFX_ByteStringC abbrName = PDF_FindAbbrName(
PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
if (!abbrName.IsEmpty()) {
pDict->ReplaceKey(key, abbrName);
key = abbrName;
}
if (value->IsName()) {
CFX_ByteString name = value->GetString();
abbrName = PDF_FindAbbrName(PDF_InlineValueAbbr,
FX_ArraySize(PDF_InlineValueAbbr), name);
if (!abbrName.IsEmpty()) {
pDict->SetAtName(key, abbrName);
}
} else {
PDF_ReplaceFull(value);
}
}
break;
}
case PDFOBJ_ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetElement(i);
if (pElement->IsName()) {
CFX_ByteString name = pElement->GetString();
CFX_ByteStringC abbrName = PDF_FindAbbrName(
PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
if (!abbrName.IsEmpty()) {
pArray->SetAt(i, new CPDF_Name(abbrName));
}
} else {
PDF_ReplaceFull(pElement);
}
}
break;
}
}
}
示例7: SearchNameNode
static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
size_t nIndex,
size_t& nCurIndex,
CFX_ByteString& csName,
CPDF_Array** ppFind,
int nLevel = 0) {
if (nLevel > nMaxRecursion)
return nullptr;
CPDF_Array* pNames = pNode->GetArrayBy("Names");
if (pNames) {
size_t nCount = pNames->GetCount() / 2;
if (nIndex >= nCurIndex + nCount) {
nCurIndex += nCount;
return nullptr;
}
if (ppFind)
*ppFind = pNames;
csName = pNames->GetStringAt((nIndex - nCurIndex) * 2);
return pNames->GetDirectObjectAt((nIndex - nCurIndex) * 2 + 1);
}
CPDF_Array* pKids = pNode->GetArrayBy("Kids");
if (!pKids)
return nullptr;
for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid)
continue;
CPDF_Object* pFound =
SearchNameNode(pKid, nIndex, nCurIndex, csName, ppFind, nLevel + 1);
if (pFound)
return pFound;
}
return nullptr;
}
示例8: GetIconPosition
void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
if (m_pIconFit) {
fLeft = 0.0f;
fBottom = 0.0f;
CPDF_Array* pA =
m_pIconFit->GetDict() ? m_pIconFit->GetDict()->GetArrayBy("A") : NULL;
if (pA) {
FX_DWORD dwCount = pA->GetCount();
if (dwCount > 0)
fLeft = pA->GetNumberAt(0);
if (dwCount > 1)
fBottom = pA->GetNumberAt(1);
}
} else {
fLeft = 0.0f;
fBottom = 0.0f;
}
}
示例9: FPDF_GetFieldAttr
FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex)
{
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
if (pObj == NULL) {
return FALSE;
}
CPDF_Array* pArray = pObj->GetArray();
if (pArray == NULL) {
return FALSE;
}
int iCount = (int)pArray->GetCount();
for (int i = 0; i < iCount; i ++) {
if (pArray->GetInteger(i) == iOptIndex) {
return TRUE;
}
}
return FALSE;
}
示例10: v_Load
FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
{
CPDF_Dictionary* pDict = pArray->GetDict(1);
CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
int i;
for (i = 0; i < 3; i ++) {
m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
}
pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
for (i = 0; i < 3; i ++) {
m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0;
}
m_Gamma = pDict->GetNumber(FX_BSTRC("Gamma"));
if (m_Gamma == 0) {
m_Gamma = 1.0f;
}
return TRUE;
}
示例11: ASSERT
FX_BOOL CPDF_FormField::IsItemSelected(int index) const {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions()) {
return FALSE;
}
if (IsOptionSelected(index)) {
return TRUE;
}
CFX_WideString opt_value = GetOptionValue(index);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict, "I");
if (!pValue) {
return FALSE;
}
}
if (pValue->IsString())
return pValue->GetUnicodeText() == opt_value;
if (pValue->IsNumber()) {
if (pValue->GetString().IsEmpty())
return FALSE;
return (pValue->GetInteger() == index);
}
CPDF_Array* pArray = pValue->AsArray();
if (!pArray)
return FALSE;
int iPos = -1;
for (int j = 0; j < CountSelectedOptions(); j++) {
if (GetSelectedOptionIndex(j) == index) {
iPos = j;
break;
}
}
for (int i = 0; i < static_cast<int>(pArray->GetCount()); i++)
if (pArray->GetDirectObjectAt(i)->GetUnicodeText() == opt_value &&
i == iPos) {
return TRUE;
}
return FALSE;
}
示例12: ParserAnnots
int ParserAnnots( CPDF_Document* pSourceDoc, CPDF_Dictionary * pPageDic, CPDF_RectArray * pRectArray, CPDF_ObjectArray * pObjectArray, int nUsage)
{
if (!pSourceDoc || !pPageDic) return FLATTEN_FAIL;
GetContentsRect( pSourceDoc, pPageDic, pRectArray );
CPDF_Array* pAnnots = pPageDic->GetArray("Annots");
if (pAnnots)
{
FX_DWORD dwSize = pAnnots->GetCount();
for (int i = 0; i < (int)dwSize; i++)
{
CPDF_Object* pObj = pAnnots->GetElementValue(i);
if (!pObj)continue;
if (pObj->GetType() == PDFOBJ_DICTIONARY)
{
CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)pObj;
CFX_ByteString sSubtype = pAnnotDic->GetString("Subtype");
if (sSubtype == "Popup")continue;
int nAnnotFlag = pAnnotDic->GetInteger("F");
if(nAnnotFlag & ANNOTFLAG_HIDDEN)
continue;
if(nUsage == FLAT_NORMALDISPLAY)
{
if(nAnnotFlag & ANNOTFLAG_INVISIBLE)
continue;
ParserStream( pPageDic, pAnnotDic, pRectArray, pObjectArray );
}
else
{
if(nAnnotFlag & ANNOTFLAG_PRINT)
ParserStream( pPageDic, pAnnotDic, pRectArray, pObjectArray );
}
}
}
return FLATTEN_SUCCESS;
}else{
return FLATTEN_NOTINGTODO;
}
}
示例13: InsertDeletePDFPage
static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages,
int nPagesToGo, CPDF_Dictionary* pPage, FX_BOOL bInsert, CFX_PtrArray& stackList)
{
CPDF_Array* pKidList = pPages->GetArray("Kids");
if (!pKidList) {
return -1;
}
int nKids = pKidList->GetCount();
for (int i = 0; i < nKids; i ++) {
CPDF_Dictionary* pKid = pKidList->GetDict(i);
if (pKid->GetString("Type") == FX_BSTRC("Page")) {
if (nPagesToGo == 0) {
if (bInsert) {
pKidList->InsertAt(i, CPDF_Reference::Create(pDoc, pPage->GetObjNum()));
pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum());
} else {
pKidList->RemoveAt(i);
}
pPages->SetAtInteger("Count", pPages->GetInteger("Count") + (bInsert ? 1 : -1));
return 1;
}
nPagesToGo --;
} else {
int nPages = pKid->GetInteger("Count");
if (nPagesToGo < nPages) {
int stackCount = stackList.GetSize();
for (int j = 0; j < stackCount; ++j) {
if (pKid == stackList[j]) {
return -1;
}
}
stackList.Add(pKid);
if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert, stackList) < 0) {
return -1;
}
stackList.RemoveAt(stackCount);
pPages->SetAtInteger("Count", pPages->GetInteger("Count") + (bInsert ? 1 : -1));
return 1;
}
nPagesToGo -= nPages;
}
}
return 0;
}
示例14: CalcEncryptKey
FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(FX_LPCBYTE password, FX_DWORD pass_size,
FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE key, FX_INT32 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;
}
FX_BYTE ukeybuf[32];
if (m_Revision == 2) {
FXSYS_memcpy32(ukeybuf, defpasscode, 32);
CRYPT_ArcFourCryptBlock(ukeybuf, 32, key, key_len);
} else {
FX_BYTE test[32], tmpkey[32];
FX_DWORD copy_len = sizeof(test);
if (copy_len > (FX_DWORD)ukey.GetLength()) {
copy_len = ukey.GetLength();
}
FXSYS_memset32(test, 0, sizeof(test));
FXSYS_memset32(tmpkey, 0, sizeof(tmpkey));
FXSYS_memcpy32(test, (FX_LPCSTR)ukey, 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);
}
FX_BYTE 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, (FX_LPBYTE)(FX_LPCSTR)id, id.GetLength());
}
CRYPT_MD5Finish(md5, ukeybuf);
return FXSYS_memcmp32(test, ukeybuf, 16) == 0;
}
if (FXSYS_memcmp32((FX_LPVOID)(FX_LPCSTR)ukey, ukeybuf, 16) == 0) {
return TRUE;
}
return FALSE;
}
示例15: GetBorderDash
void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const {
CPDF_Array* pDash = NULL;
CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border");
if (pBorder) {
pDash = pBorder->GetArrayAt(3);
} else {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS");
if (pBSDict) {
pDash = pBSDict->GetArrayBy("D");
}
}
if (pDash) {
for (int i = 0, sz = pDash->GetCount(); i < sz; i++) {
array.Add(pDash->GetIntegerAt(i));
}
}
}