本文整理汇总了C++中CPDF_Object::AsDictionary方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Object::AsDictionary方法的具体用法?C++ CPDF_Object::AsDictionary怎么用?C++ CPDF_Object::AsDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Object
的用法示例。
在下文中一共展示了CPDF_Object::AsDictionary方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOCGVE
FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
FX_BOOL bFromConfig,
int nLevel) {
if (nLevel > 32) {
return FALSE;
}
if (!pExpression) {
return FALSE;
}
int32_t iCount = pExpression->GetCount();
CPDF_Object* pOCGObj;
CFX_ByteString csOperator = pExpression->GetStringAt(0);
if (csOperator == "Not") {
pOCGObj = pExpression->GetElementValue(1);
if (!pOCGObj)
return FALSE;
if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
return !(bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict));
if (CPDF_Array* pArray = pOCGObj->AsArray())
return !GetOCGVE(pArray, bFromConfig, nLevel + 1);
return FALSE;
}
if (csOperator == "Or" || csOperator == "And") {
FX_BOOL bValue = FALSE;
for (int32_t i = 1; i < iCount; i++) {
pOCGObj = pExpression->GetElementValue(1);
if (!pOCGObj) {
continue;
}
FX_BOOL bItem = FALSE;
if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
bItem = bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict);
else if (CPDF_Array* pArray = pOCGObj->AsArray())
bItem = GetOCGVE(pArray, bFromConfig, nLevel + 1);
if (i == 1) {
bValue = bItem;
} else {
if (csOperator == "Or") {
bValue = bValue || bItem;
} else {
bValue = bValue && bItem;
}
}
}
return bValue;
}
return FALSE;
}
示例2: LoadOCMDState
FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict,
FX_BOOL bFromConfig) {
CPDF_Array* pVE = pOCMDDict->GetArrayBy("VE");
if (pVE) {
return GetOCGVE(pVE, bFromConfig);
}
CFX_ByteString csP = pOCMDDict->GetStringBy("P", "AnyOn");
CPDF_Object* pOCGObj = pOCMDDict->GetElementValue("OCGs");
if (!pOCGObj)
return TRUE;
if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
return bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict);
CPDF_Array* pArray = pOCGObj->AsArray();
if (!pArray)
return TRUE;
FX_BOOL bState = FALSE;
if (csP == "AllOn" || csP == "AllOff") {
bState = TRUE;
}
int32_t iCount = pArray->GetCount();
for (int32_t i = 0; i < iCount; i++) {
FX_BOOL bItem = TRUE;
CPDF_Dictionary* pItemDict = pArray->GetDictAt(i);
if (pItemDict)
bItem = bFromConfig ? LoadOCGState(pItemDict) : GetOCGVisible(pItemDict);
if ((csP == "AnyOn" && bItem) || (csP == "AnyOff" && !bItem))
return TRUE;
if ((csP == "AllOn" && !bItem) || (csP == "AllOff" && bItem))
return FALSE;
}
return bState;
}
示例3: ProcOpenAction
FX_BOOL CPDFSDK_Document::ProcOpenAction() {
if (!m_pDoc)
return FALSE;
CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
if (!pRoot)
return FALSE;
CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");
if (!pOpenAction)
pOpenAction = pRoot->GetArray("OpenAction");
if (!pOpenAction)
return FALSE;
if (pOpenAction->IsArray())
return TRUE;
if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) {
CPDF_Action action(pDict);
if (m_pEnv->GetActionHander())
m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
return TRUE;
}
return FALSE;
}
示例4: GetDictAt
CPDF_Dictionary* CPDF_Array::GetDictAt(size_t i) const {
CPDF_Object* p = GetDirectObjectAt(i);
if (!p)
return nullptr;
if (CPDF_Dictionary* pDict = p->AsDictionary())
return pDict;
if (CPDF_Stream* pStream = p->AsStream())
return pStream->GetDict();
return nullptr;
}
示例5: GetDict
CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const {
CPDF_Object* p = GetElementValue(key);
if (!p)
return nullptr;
if (CPDF_Dictionary* pDict = p->AsDictionary())
return pDict;
if (CPDF_Stream* pStream = p->AsStream())
return pStream->GetDict();
return nullptr;
}
示例6: LookupNamedDest
CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
const CFX_ByteStringC& sName) {
CPDF_Object* pValue = LookupValue(sName);
if (!pValue) {
CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests");
if (!pDests)
return nullptr;
pValue = pDests->GetElementValue(sName);
}
if (!pValue)
return nullptr;
if (CPDF_Array* pArray = pValue->AsArray())
return pArray;
if (CPDF_Dictionary* pDict = pValue->AsDictionary())
return pDict->GetArrayBy("D");
return nullptr;
}
示例7: GetNewObjId
FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
ObjectNumberMap* pObjNumberMap,
CPDF_Reference* pRef) {
if (!pRef)
return 0;
FX_DWORD dwObjnum = pRef->GetRefObjNum();
FX_DWORD dwNewObjNum = 0;
const auto it = pObjNumberMap->find(dwObjnum);
if (it != pObjNumberMap->end())
dwNewObjNum = it->second;
if (dwNewObjNum)
return dwNewObjNum;
CPDF_Object* pDirect = pRef->GetDirect();
if (!pDirect)
return 0;
CPDF_Object* pClone = pDirect->Clone();
if (!pClone)
return 0;
if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) {
if (pDictClone->KeyExist("Type")) {
CFX_ByteString strType = pDictClone->GetString("Type");
if (!FXSYS_stricmp(strType, "Pages")) {
pDictClone->Release();
return 4;
}
if (!FXSYS_stricmp(strType, "Page")) {
pDictClone->Release();
return 0;
}
}
}
dwNewObjNum = pDoc->AddIndirectObject(pClone);
(*pObjNumberMap)[dwObjnum] = dwNewObjNum;
if (!UpdateReference(pClone, pDoc, pObjNumberMap)) {
pClone->Release();
return 0;
}
return dwNewObjNum;
}
示例8: Handle_BeginMarkedContent_Dictionary
void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
if (!m_Options.m_bMarkedContent) {
return;
}
CFX_ByteString tag = GetString(1);
CPDF_Object* pProperty = GetObject(0);
if (!pProperty) {
return;
}
FX_BOOL bDirect = TRUE;
if (pProperty->IsName()) {
pProperty = FindResourceObj("Properties", pProperty->GetString());
if (!pProperty)
return;
bDirect = FALSE;
}
if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect);
}
}
示例9: GetLabel
CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
CFX_WideString wsLabel;
if (!m_pDocument) {
return wsLabel;
}
CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
if (!pPDFRoot) {
return wsLabel;
}
CPDF_Dictionary* pLabels = pPDFRoot->GetDictBy("PageLabels");
CPDF_NumberTree numberTree(pLabels);
CPDF_Object* pValue = NULL;
int n = nPage;
while (n >= 0) {
pValue = numberTree.LookupValue(n);
if (pValue) {
break;
}
n--;
}
if (pValue) {
pValue = pValue->GetDirect();
if (CPDF_Dictionary* pLabel = pValue->AsDictionary()) {
if (pLabel->KeyExist("P")) {
wsLabel += pLabel->GetUnicodeTextBy("P");
}
CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", NULL);
int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1);
CFX_WideString wsNumPortion =
_GetLabelNumPortion(nLabelNum, bsNumberingStyle);
wsLabel += wsNumPortion;
return wsLabel;
}
}
wsLabel.Format(L"%d", nPage + 1);
return wsLabel;
}
示例10: FPDFDOC_GetAnnotAP
CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
CPDF_Annot::AppearanceMode mode) {
CPDF_Dictionary* pAP = pAnnotDict->GetDictBy("AP");
if (!pAP) {
return nullptr;
}
const FX_CHAR* ap_entry = "N";
if (mode == CPDF_Annot::Down)
ap_entry = "D";
else if (mode == CPDF_Annot::Rollover)
ap_entry = "R";
if (!pAP->KeyExist(ap_entry))
ap_entry = "N";
CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry);
if (!psub)
return nullptr;
if (CPDF_Stream* pStream = psub->AsStream())
return pStream;
if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
CFX_ByteString as = pAnnotDict->GetStringBy("AS");
if (as.IsEmpty()) {
CFX_ByteString value = pAnnotDict->GetStringBy("V");
if (value.IsEmpty()) {
CPDF_Dictionary* pParentDict = pAnnotDict->GetDictBy("Parent");
value = pParentDict ? pParentDict->GetStringBy("V") : CFX_ByteString();
}
if (value.IsEmpty() || !pDict->KeyExist(value))
as = "Off";
else
as = value;
}
return pDict->GetStreamBy(as);
}
return nullptr;
}
示例11: LoadDocTree
void CPDF_StructTreeImpl::LoadDocTree() {
m_pPage = nullptr;
if (!m_pTreeRoot)
return;
CPDF_Object* pKids = m_pTreeRoot->GetDirectObjectBy("K");
if (!pKids)
return;
if (CPDF_Dictionary* pDict = pKids->AsDictionary()) {
m_Kids.push_back(CFX_RetainPtr<CPDF_StructElementImpl>(
new CPDF_StructElementImpl(this, nullptr, pDict)));
return;
}
CPDF_Array* pArray = pKids->AsArray();
if (!pArray)
return;
for (size_t i = 0; i < pArray->GetCount(); i++) {
m_Kids.push_back(CFX_RetainPtr<CPDF_StructElementImpl>(
new CPDF_StructElementImpl(this, nullptr, pArray->GetDictAt(i))));
}
}
示例12: locker
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPage_TransFormWithClip(FPDF_PAGE page,
const FS_MATRIX* matrix,
const FS_RECTF* clipRect) {
if (!matrix && !clipRect)
return false;
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return false;
std::ostringstream textBuf;
textBuf << "q ";
if (clipRect) {
CFX_FloatRect rect = CFXFloatRectFromFSRECTF(*clipRect);
rect.Normalize();
textBuf << ByteString::Format("%f %f %f %f re W* n ", rect.left,
rect.bottom, rect.Width(), rect.Height());
}
if (matrix) {
textBuf << ByteString::Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,
matrix->c, matrix->d, matrix->e, matrix->f);
}
CPDF_Dictionary* pPageDict = pPage->GetDict();
CPDF_Object* pContentObj = GetPageContent(pPageDict);
if (!pContentObj)
return false;
CPDF_Document* pDoc = pPage->GetDocument();
if (!pDoc)
return false;
CPDF_Stream* pStream =
pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDoc->New<CPDF_Dictionary>());
pStream->SetDataFromStringstream(&textBuf);
CPDF_Stream* pEndStream =
pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDoc->New<CPDF_Dictionary>());
pEndStream->SetData(ByteStringView(" Q").span());
if (CPDF_Array* pContentArray = ToArray(pContentObj)) {
pContentArray->InsertAt(0, pStream->MakeReference(pDoc));
pContentArray->Add(pEndStream->MakeReference(pDoc));
} else if (pContentObj->IsStream() && !pContentObj->IsInline()) {
pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->Add(pStream->MakeReference(pDoc));
pContentArray->Add(pContentObj->MakeReference(pDoc));
pContentArray->Add(pEndStream->MakeReference(pDoc));
pPageDict->SetFor(pdfium::page_object::kContents,
pContentArray->MakeReference(pDoc));
}
// Need to transform the patterns as well.
CPDF_Dictionary* pRes =
pPageDict->GetDictFor(pdfium::page_object::kResources);
if (!pRes)
return true;
CPDF_Dictionary* pPatternDict = pRes->GetDictFor("Pattern");
if (!pPatternDict)
return true;
CPDF_DictionaryLocker locker(pPatternDict);
for (const auto& it : locker) {
CPDF_Object* pObj = it.second.get();
if (pObj->IsReference())
pObj = pObj->GetDirect();
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
else if (CPDF_Stream* pObjStream = pObj->AsStream())
pDict = pObjStream->GetDict();
else
continue;
if (matrix) {
CFX_Matrix m = CFXMatrixFromFSMatrix(*matrix);
pDict->SetMatrixFor("Matrix", pDict->GetMatrixFor("Matrix") * m);
}
}
return true;
}
示例13: rect
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
FS_MATRIX* matrix,
FS_RECTF* clipRect) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return FALSE;
CFX_ByteTextBuf textBuf;
textBuf << "q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right,
clipRect->top);
rect.Normalize();
CFX_ByteString bsClipping;
bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
rect.Width(), rect.Height());
textBuf << bsClipping;
CFX_ByteString bsMatix;
bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c,
matrix->d, matrix->e, matrix->f);
textBuf << bsMatix;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetElement("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr;
if (!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = new CPDF_Dictionary;
CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = new CPDF_Dictionary;
CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
if (CPDF_Array* pArray = ToArray(pContentObj)) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
if (CPDF_Array* pArray = pDirectObj->AsArray()) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream);
pPageDic->SetAtReference("Contents", pDoc,
pDoc->AddIndirectObject(pContentArray));
}
}
}
// Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources");
if (pRes) {
CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern");
if (pPattenDict) {
for (const auto& it : *pPattenDict) {
CPDF_Object* pObj = it.second;
if (pObj->IsReference())
pObj = pObj->GetDirect();
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
else if (CPDF_Stream* pStream = pObj->AsStream())
pDict = pStream->GetDict();
else
continue;
CFX_Matrix m = pDict->GetMatrixBy("Matrix");
CFX_Matrix t = *(CFX_Matrix*)matrix;
m.Concat(t);
pDict->SetAtMatrix("Matrix", m);
}
}
}
return TRUE;
}