本文整理汇总了C++中CPDF_Dictionary::KeyExist方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::KeyExist方法的具体用法?C++ CPDF_Dictionary::KeyExist怎么用?C++ CPDF_Dictionary::KeyExist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::KeyExist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PageDictGetInheritableTag
CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
CPDF_Dictionary* pDict,
const CFX_ByteString& bsSrcTag) {
if (!pDict || bsSrcTag.IsEmpty())
return nullptr;
if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type"))
return nullptr;
CPDF_Object* pType = pDict->GetObjectFor("Type")->GetDirect();
if (!ToName(pType))
return nullptr;
if (pType->GetString().Compare("Page"))
return nullptr;
CPDF_Dictionary* pp =
ToDictionary(pDict->GetObjectFor("Parent")->GetDirect());
if (!pp)
return nullptr;
if (pDict->KeyExist(bsSrcTag))
return pDict->GetObjectFor(bsSrcTag);
while (pp) {
if (pp->KeyExist(bsSrcTag))
return pp->GetObjectFor(bsSrcTag);
if (!pp->KeyExist("Parent"))
break;
pp = ToDictionary(pp->GetObjectFor("Parent")->GetDirect());
}
return nullptr;
}
示例2: PageDictGetInheritableTag
CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
CPDF_Dictionary* pDict,
CFX_ByteString nSrctag) {
if (!pDict || nSrctag.IsEmpty())
return nullptr;
if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type"))
return nullptr;
CPDF_Object* pType = pDict->GetElement("Type")->GetDirect();
if (!ToName(pType))
return nullptr;
if (pType->GetString().Compare("Page"))
return nullptr;
CPDF_Dictionary* pp = ToDictionary(pDict->GetElement("Parent")->GetDirect());
if (!pp)
return nullptr;
if (pDict->KeyExist((const char*)nSrctag))
return pDict->GetElement((const char*)nSrctag);
while (pp) {
if (pp->KeyExist((const char*)nSrctag)) {
return pp->GetElement((const char*)nSrctag);
}
if (!pp->KeyExist("Parent")) {
break;
}
pp = ToDictionary(pp->GetElement("Parent")->GetDirect());
}
return nullptr;
}
示例3: LoadOCGState
FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary *pOCGDict) const
{
if (!FPDFDOC_OCG_HasIntent(pOCGDict, FX_BSTRC("View"), FX_BSTRC("View"))) {
return TRUE;
}
CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType);
CPDF_Dictionary *pUsage = pOCGDict->GetDict(FX_BSTRC("Usage"));
if (pUsage) {
CPDF_Dictionary *pState = pUsage->GetDict(csState);
if (pState) {
CFX_ByteString csFind = csState + FX_BSTRC("State");
if (pState->KeyExist(csFind)) {
return pState->GetString(csFind) != FX_BSTRC("OFF");
}
}
if (csState != FX_BSTRC("View")) {
pState = pUsage->GetDict(FX_BSTRC("View"));
if (pState && pState->KeyExist(FX_BSTRC("ViewState"))) {
return pState->GetString(FX_BSTRC("ViewState")) != FX_BSTRC("OFF");
}
}
}
FX_BOOL bDefValid = FALSE;
return LoadOCGStateFromConfig(csState, pOCGDict, bDefValid);
}
示例4: LoadField
void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) {
if (nLevel > nMaxRecursion) {
return;
}
if (pFieldDict == NULL) {
return;
}
FX_DWORD dwParentObjNum = pFieldDict->GetObjNum();
CPDF_Array* pKids = pFieldDict->GetArray("Kids");
if (!pKids) {
AddTerminalField(pFieldDict);
return;
}
CPDF_Dictionary* pFirstKid = pKids->GetDict(0);
if (pFirstKid == NULL) {
return;
}
if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) {
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pChildDict = pKids->GetDict(i);
if (pChildDict) {
if (pChildDict->GetObjNum() != dwParentObjNum) {
LoadField(pChildDict, nLevel + 1);
}
}
}
} else {
AddTerminalField(pFieldDict);
}
}
示例5: CPDFPageFromFPDFPage
DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
!pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
"Page")) {
return -1;
}
CPDF_Dictionary* pDict = pPage->m_pFormDict;
if (!pDict)
return -1;
while (pDict) {
if (pDict->KeyExist("Rotate")) {
CPDF_Object* pRotateObj = pDict->GetElement("Rotate")->GetDirect();
return pRotateObj ? pRotateObj->GetInteger() / 90 : 0;
}
if (!pDict->KeyExist("Parent"))
break;
pDict = ToDictionary(pDict->GetElement("Parent")->GetDirect());
}
return 0;
}
示例6: GetFileName
FX_BOOL CPDF_FileSpec::GetFileName(CFX_WideString &csFileName) const
{
if (m_pObj == NULL) {
return FALSE;
}
if (m_pObj->GetType() == PDFOBJ_DICTIONARY) {
CPDF_Dictionary* pDict = (CPDF_Dictionary*)m_pObj;
csFileName = pDict->GetUnicodeText(FX_BSTRC("UF"));
if (csFileName.IsEmpty()) {
csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F")));
}
if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) {
return TRUE;
}
if (csFileName.IsEmpty()) {
if (pDict->KeyExist(FX_BSTRC("DOS"))) {
csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DOS")));
} else if (pDict->KeyExist(FX_BSTRC("Mac"))) {
csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("Mac")));
} else if (pDict->KeyExist(FX_BSTRC("Unix"))) {
csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("Unix")));
} else {
return FALSE;
}
}
} else {
csFileName = CFX_WideString::FromLocal(m_pObj->GetString());
}
csFileName = FILESPEC_DecodeFileName(csFileName);
return TRUE;
}
示例7: LoadField
void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) {
if (nLevel > nMaxRecursion)
return;
if (!pFieldDict)
return;
uint32_t dwParentObjNum = pFieldDict->GetObjNum();
CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids");
if (!pKids) {
AddTerminalField(pFieldDict);
return;
}
CPDF_Dictionary* pFirstKid = pKids->GetDictAt(0);
if (!pFirstKid)
return;
if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) {
for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pChildDict = pKids->GetDictAt(i);
if (pChildDict) {
if (pChildDict->GetObjNum() != dwParentObjNum)
LoadField(pChildDict, nLevel + 1);
}
}
} else {
AddTerminalField(pFieldDict);
}
}
示例8: CheckUnSupportError
void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code) {
// Security
if (err_code == FPDF_ERR_SECURITY) {
FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY);
return;
}
if (!pDoc)
return;
// Portfolios and Packages
CPDF_Dictionary* pRootDict = pDoc->GetRoot();
if (pRootDict) {
CFX_ByteString cbString;
if (pRootDict->KeyExist("Collection")) {
FPDF_UnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION);
return;
}
if (pRootDict->KeyExist("Names")) {
CPDF_Dictionary* pNameDict = pRootDict->GetDict("Names");
if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) {
FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT);
return;
}
if (pNameDict && pNameDict->KeyExist("JavaScript")) {
CPDF_Dictionary* pJSDict = pNameDict->GetDict("JavaScript");
CPDF_Array* pArray = pJSDict ? pJSDict->GetArray("Names") : NULL;
if (pArray) {
int nCount = pArray->GetCount();
for (int i = 0; i < nCount; i++) {
CFX_ByteString cbStr = pArray->GetString(i);
if (cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0) {
FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW);
return;
}
}
}
}
}
}
// SharedForm
CPDF_Metadata metaData(pDoc);
const CXML_Element* pElement = metaData.GetRoot();
if (pElement)
CheckSharedForm(pElement, "workflowType");
// XFA Forms
CPDF_InterForm* pInterForm = new CPDF_InterForm(pDoc, FALSE);
if (pInterForm->HasXFAForm()) {
FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM);
}
delete pInterForm;
}
示例9: CheckUnSupportError
void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) {
// Security
if (err_code == FPDF_ERR_SECURITY) {
FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY);
return;
}
if (!pDoc)
return;
// Portfolios and Packages
CPDF_Dictionary* pRootDict = pDoc->GetRoot();
if (pRootDict) {
CFX_ByteString cbString;
if (pRootDict->KeyExist("Collection")) {
FPDF_UnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION);
return;
}
if (pRootDict->KeyExist("Names")) {
CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names");
if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) {
FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT);
return;
}
if (pNameDict && pNameDict->KeyExist("JavaScript")) {
CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript");
CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayFor("Names") : nullptr;
if (pArray) {
for (size_t i = 0; i < pArray->GetCount(); i++) {
CFX_ByteString cbStr = pArray->GetStringAt(i);
if (cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0) {
FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW);
return;
}
}
}
}
}
}
// SharedForm
CPDF_Metadata metaData(pDoc);
const CXML_Element* pElement = metaData.GetRoot();
if (pElement)
CheckSharedForm(pElement, "workflowType");
#ifndef PDF_ENABLE_XFA
// XFA Forms
CPDF_InterForm interform(pDoc);
if (interform.HasXFAForm())
FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM);
#endif // PDF_ENABLE_XFA
}
示例10: ChangeSlash
CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec)
{
CFX_WideString wsFileName;
if (pFileSpec->GetType() == PDFOBJ_DICTIONARY) {
CPDF_Dictionary* pDict = (CPDF_Dictionary*)pFileSpec;
wsFileName = pDict->GetUnicodeText(FX_BSTRC("UF"));
if (wsFileName.IsEmpty()) {
wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F")));
}
if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) {
return wsFileName;
}
if (wsFileName.IsEmpty() && pDict->KeyExist(FX_BSTRC("DOS"))) {
wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DOS")));
}
} else {
wsFileName = CFX_WideString::FromLocal(pFileSpec->GetString());
}
if (wsFileName[0] != '/') {
return ChangeSlash(wsFileName);
}
if (wsFileName[2] == '/') {
CFX_WideString result;
result += wsFileName[1];
result += ':';
result += ChangeSlash(((FX_LPCWSTR)wsFileName) + 2);
return result;
} else {
CFX_WideString result;
result += '\\';
result += ChangeSlash(wsFileName);
return result;
}
}
示例11: FindPDFPage
CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages,
int iPage,
int nPagesToGo,
int level) {
CPDF_Array* pKidList = pPages->GetArrayFor("Kids");
if (!pKidList)
return nPagesToGo == 0 ? pPages : nullptr;
if (level >= FX_MAX_PAGE_LEVEL)
return nullptr;
for (size_t i = 0; i < pKidList->GetCount(); i++) {
CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
if (!pKid) {
nPagesToGo--;
continue;
}
if (pKid == pPages)
continue;
if (!pKid->KeyExist("Kids")) {
if (nPagesToGo == 0)
return pKid;
m_PageList.SetAt(iPage - nPagesToGo, pKid->GetObjNum());
nPagesToGo--;
} else {
int nPages = pKid->GetIntegerFor("Count");
if (nPagesToGo < nPages)
return FindPDFPage(pKid, iPage, nPagesToGo, level + 1);
nPagesToGo -= nPages;
}
}
return nullptr;
}
示例12: RealizeResource
CFX_ByteString CPDF_PageContentGenerate::RealizeResource(
CPDF_Object* pResourceObj,
const FX_CHAR* szType) {
if (m_pPage->m_pResources == NULL) {
m_pPage->m_pResources = new CPDF_Dictionary;
int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources);
m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum);
}
CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDict(szType);
if (pResList == NULL) {
pResList = new CPDF_Dictionary;
m_pPage->m_pResources->SetAt(szType, pResList);
}
m_pDocument->AddIndirectObject(pResourceObj);
CFX_ByteString name;
int idnum = 1;
while (1) {
name.Format("FX%c%d", szType[0], idnum);
if (!pResList->KeyExist(name)) {
break;
}
idnum++;
}
pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum());
return name;
}
示例13: RealizeResource
CFX_ByteString CPDF_PageContentGenerator::RealizeResource(
CPDF_Object* pResourceObj,
const CFX_ByteString& bsType) {
if (!m_pPage->m_pResources) {
m_pPage->m_pResources =
new CPDF_Dictionary(m_pDocument->GetByteStringPool());
m_pPage->m_pFormDict->SetReferenceFor(
"Resources", m_pDocument,
m_pDocument->AddIndirectObject(m_pPage->m_pResources));
}
CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType);
if (!pResList) {
pResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool());
m_pPage->m_pResources->SetFor(bsType, pResList);
}
CFX_ByteString name;
int idnum = 1;
while (1) {
name.Format("FX%c%d", bsType[0], idnum);
if (!pResList->KeyExist(name)) {
break;
}
idnum++;
}
pResList->SetReferenceFor(name, m_pDocument,
m_pDocument->AddIndirectObject(pResourceObj));
return name;
}
示例14: if
std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
CPDF_Dictionary* pFontDict) {
CFX_ByteString type = pFontDict->GetStringFor("Subtype");
std::unique_ptr<CPDF_Font> pFont;
if (type == "TrueType") {
CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4);
for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) {
if (tag == CFX_ByteString(kChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
pFont.reset(new CPDF_CIDFont);
break;
}
}
if (!pFont)
pFont.reset(new CPDF_TrueTypeFont);
} else if (type == "Type3") {
pFont.reset(new CPDF_Type3Font);
} else if (type == "Type0") {
pFont.reset(new CPDF_CIDFont);
} else {
pFont.reset(new CPDF_Type1Font);
}
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont");
return pFont->Load() ? std::move(pFont) : nullptr;
}
示例15: _CountPages
static int _CountPages(CPDF_Dictionary* pPages, int level) {
if (level > 128) {
return 0;
}
int count = pPages->GetInteger("Count");
if (count > 0 && count < FPDF_PAGE_MAX_NUM) {
return count;
}
CPDF_Array* pKidList = pPages->GetArray("Kids");
if (!pKidList) {
return 0;
}
count = 0;
for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) {
CPDF_Dictionary* pKid = pKidList->GetDict(i);
if (!pKid) {
continue;
}
if (!pKid->KeyExist("Kids")) {
count++;
} else {
count += _CountPages(pKid, level + 1);
}
}
pPages->SetAtInteger("Count", count);
return count;
}