本文整理汇总了C++中CPDF_Object::IsReference方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Object::IsReference方法的具体用法?C++ CPDF_Object::IsReference怎么用?C++ CPDF_Object::IsReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Object
的用法示例。
在下文中一共展示了CPDF_Object::IsReference方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: ExportSubmitFile
bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
int fileType,
FPDF_DWORD encodeType,
FPDF_DWORD flag) {
if (!m_pContext->GetXFADocView())
return false;
CFX_ByteString content;
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
if (!pFormFillEnv)
return false;
CFX_RetainPtr<IFX_SeekableStream> fileStream =
MakeSeekableStream(pFileHandler);
if (fileType == FXFA_SAVEAS_XML) {
const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
fileStream->WriteBlock(kContent, 0, strlen(kContent));
m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, fileStream,
nullptr);
return true;
}
if (fileType != FXFA_SAVEAS_XDP)
return true;
if (!flag) {
flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
}
if (!m_pContext->GetPDFDoc()) {
fileStream->Flush();
return false;
}
CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
if (!pRoot) {
fileStream->Flush();
return false;
}
CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
if (!pAcroForm) {
fileStream->Flush();
return false;
}
CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA"));
if (!pArray) {
fileStream->Flush();
return false;
}
int size = pArray->GetCount();
for (int i = 1; i < size; i += 2) {
CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
if (!pPrePDFObj->IsString())
continue;
if (!pPDFObj->IsReference())
continue;
CPDF_Object* pDirectObj = pPDFObj->GetDirect();
if (!pDirectObj->IsStream())
continue;
if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG))
continue;
if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE))
continue;
if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET))
continue;
if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS))
continue;
if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA))
continue;
if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF))
continue;
if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
continue;
if (pPrePDFObj->GetString() == "form") {
m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Form, fileStream,
nullptr);
} else if (pPrePDFObj->GetString() == "datasets") {
m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Datasets, fileStream,
nullptr);
} else {
// PDF,creator.
}
}
return true;
}
示例4: ExportData
void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
const CFX_WideString& wsFilePath,
bool bXDP) {
if (hDoc != m_pContext->GetXFADoc())
return;
if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) {
return;
}
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
if (!pFormFillEnv)
return;
int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
CFX_ByteString bs = wsFilePath.UTF16LE_Encode();
if (wsFilePath.IsEmpty()) {
if (!pFormFillEnv->GetFormFillInfo() ||
!pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) {
return;
}
CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse();
bs = filepath.UTF16LE_Encode();
}
int len = bs.GetLength();
FPDF_FILEHANDLER* pFileHandler =
pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
(FPDF_WIDESTRING)bs.GetBuffer(len), "wb");
bs.ReleaseBuffer(len);
if (!pFileHandler)
return;
CFX_RetainPtr<IFX_SeekableStream> fileWrite =
MakeSeekableStream(pFileHandler);
CFX_ByteString content;
if (fileType == FXFA_SAVEAS_XML) {
content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
content.GetLength());
m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Data,
fileWrite, nullptr);
} else if (fileType == FXFA_SAVEAS_XDP) {
if (!m_pContext->GetPDFDoc())
return;
CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
if (!pRoot)
return;
CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
if (!pAcroForm)
return;
CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA"));
if (!pArray)
return;
int size = pArray->GetCount();
for (int i = 1; i < size; i += 2) {
CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
if (!pPrePDFObj->IsString())
continue;
if (!pPDFObj->IsReference())
continue;
CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect());
if (!pStream)
continue;
if (pPrePDFObj->GetString() == "form") {
m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Form,
fileWrite, nullptr);
continue;
}
if (pPrePDFObj->GetString() == "datasets") {
m_pContext->GetXFADocView()->GetDoc()->SavePackage(
XFA_HASHCODE_Datasets, fileWrite, nullptr);
continue;
}
if (i == size - 1) {
CFX_WideString wPath = CFX_WideString::FromUTF16LE(
reinterpret_cast<const unsigned short*>(bs.c_str()),
bs.GetLength() / sizeof(unsigned short));
CFX_ByteString bPath = wPath.UTF8Encode();
const char* szFormat =
"\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
content.Format(szFormat, bPath.c_str());
fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
content.GetLength());
}
std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc);
pAcc->LoadAllData(pStream);
fileWrite->WriteBlock(pAcc->GetData(), fileWrite->GetSize(),
pAcc->GetSize());
}
}
fileWrite->Flush();
}
示例5: SafeGetDirect
CPDF_Object* CPDF_Reference::SafeGetDirect() const {
CPDF_Object* obj = GetDirect();
return (obj && !obj->IsReference()) ? obj : nullptr;
}
示例6: if
//.........这里部分代码省略.........
pNewOXbjectDic->SetNameFor("Subtype", "Form");
pNewOXbjectDic->SetIntegerFor("FormType", 1);
pNewOXbjectDic->SetNameFor("Name", "FRM");
CFX_FloatRect rcBBox = pPageDict->GetRectFor("ArtBox");
pNewOXbjectDic->SetRectFor("BBox", rcBBox);
}
for (int i = 0; i < nStreams; i++) {
CPDF_Dictionary* pAnnotDic = ObjectArray.GetAt(i);
if (!pAnnotDic)
continue;
CFX_FloatRect rcAnnot = pAnnotDic->GetRectFor("Rect");
rcAnnot.Normalize();
CFX_ByteString sAnnotState = pAnnotDic->GetStringFor("AS");
CPDF_Dictionary* pAnnotAP = pAnnotDic->GetDictFor("AP");
if (!pAnnotAP)
continue;
CPDF_Stream* pAPStream = pAnnotAP->GetStreamFor("N");
if (!pAPStream) {
CPDF_Dictionary* pAPDic = pAnnotAP->GetDictFor("N");
if (!pAPDic)
continue;
if (!sAnnotState.IsEmpty()) {
pAPStream = pAPDic->GetStreamFor(sAnnotState);
} else {
auto it = pAPDic->begin();
if (it != pAPDic->end()) {
CPDF_Object* pFirstObj = it->second;
if (pFirstObj) {
if (pFirstObj->IsReference())
pFirstObj = pFirstObj->GetDirect();
if (!pFirstObj->IsStream())
continue;
pAPStream = pFirstObj->AsStream();
}
}
}
}
if (!pAPStream)
continue;
CPDF_Dictionary* pAPDic = pAPStream->GetDict();
CFX_Matrix matrix = pAPDic->GetMatrixFor("Matrix");
CFX_FloatRect rcStream;
if (pAPDic->KeyExist("Rect"))
rcStream = pAPDic->GetRectFor("Rect");
else if (pAPDic->KeyExist("BBox"))
rcStream = pAPDic->GetRectFor("BBox");
if (rcStream.IsEmpty())
continue;
CPDF_Object* pObj = pAPStream;
if (pObj) {
CPDF_Dictionary* pObjDic = pObj->GetDict();
if (pObjDic) {
pObjDic->SetNameFor("Type", "XObject");
pObjDic->SetNameFor("Subtype", "Form");
}
}