本文整理汇总了C++中CPDF_Stream类的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Stream类的具体用法?C++ CPDF_Stream怎么用?C++ CPDF_Stream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPDF_Stream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FPDFDOC_GetAnnotAP
void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
CFX_Matrix* pMatrix,
CPDF_Page* pPage,
CPDF_Annot::AppearanceMode mode,
const CPDF_RenderOptions* pOptions) {
if (m_pWidgetDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN)
return;
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
if (!pStream)
return;
CFX_FloatRect form_bbox = pStream->GetDict()->GetRectBy("BBox");
CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix");
form_matrix.TransformRect(form_bbox);
CFX_FloatRect arect = m_pWidgetDict->GetRectBy("Rect");
CFX_Matrix matrix;
matrix.MatchRect(arect, form_bbox);
matrix.Concat(*pMatrix);
CPDF_Form form(m_pField->m_pForm->m_pDocument,
m_pField->m_pForm->m_pFormDict->GetDictBy("DR"), pStream);
form.ParseContent(nullptr, nullptr, nullptr);
CPDF_RenderContext context(pPage);
context.AppendLayer(&form, &matrix);
context.Render(pDevice, pOptions, nullptr);
}
示例2: lpfCallback
CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpfCallback, FX_LPVOID pUserData) const
{
CPDF_Dictionary *pCloneDict = (CPDF_Dictionary*)m_pDict->Clone(bDirect);
IFX_FileStream *pFS = NULL;
if (lpfCallback) {
pFS = lpfCallback((CPDF_Stream*)this, pUserData);
}
if (!pFS) {
CPDF_StreamAcc acc;
acc.LoadAllData(this, TRUE);
FX_DWORD streamSize = acc.GetSize();
return new CPDF_Stream(acc.DetachData(), streamSize, pCloneDict);
}
CPDF_Stream* pObj = new CPDF_Stream(NULL, 0, NULL);
CPDF_StreamFilter *pSF = GetStreamFilter(TRUE);
if (pSF) {
FX_LPBYTE pBuf = FX_Alloc(FX_BYTE, 4096);
FX_DWORD dwRead;
do {
dwRead = pSF->ReadBlock(pBuf, 4096);
if (dwRead) {
pFS->WriteBlock(pBuf, dwRead);
}
} while (dwRead == 4096);
pFS->Flush();
FX_Free(pBuf);
delete pSF;
}
pObj->InitStream((IFX_FileRead*)pFS, pCloneDict);
return pObj;
}
示例3: FPDFDOC_GetAnnotAP
void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
CFX_AffineMatrix* pMatrix,
CPDF_Page* pPage,
CPDF_Annot::AppearanceMode mode,
const CPDF_RenderOptions* pOptions) {
if (m_pWidgetDict->GetInteger("F") & ANNOTFLAG_HIDDEN) {
return;
}
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
if (pStream == NULL) {
return;
}
CFX_FloatRect form_bbox = pStream->GetDict()->GetRect("BBox");
CFX_AffineMatrix form_matrix = pStream->GetDict()->GetMatrix("Matrix");
form_matrix.TransformRect(form_bbox);
CFX_FloatRect arect = m_pWidgetDict->GetRect("Rect");
CFX_AffineMatrix matrix;
matrix.MatchRect(arect, form_bbox);
matrix.Concat(*pMatrix);
CPDF_Form form(m_pField->m_pForm->m_pDocument,
m_pField->m_pForm->m_pFormDict->GetDict("DR"), pStream);
form.ParseContent(NULL, NULL, NULL, NULL);
CPDF_RenderContext context;
context.Create(pPage);
context.DrawObjectList(pDevice, &form, &matrix, pOptions);
}
示例4: ASSERT
void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias)
{
if (!pFont) return;
ASSERT(m_pAnnotDict != NULL);
ASSERT(m_pDocument != NULL);
CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP");
if (pAPDict == NULL)
{
pAPDict = new CPDF_Dictionary;
m_pAnnotDict->SetAt("AP", pAPDict);
}
//to avoid checkbox and radiobutton
CPDF_Object* pObject = pAPDict->GetElement(m_sAPType);
if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY)
return;
CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType);
if (pStream == NULL)
{
pStream = new CPDF_Stream(NULL, 0, NULL);
FX_INT32 objnum = m_pDocument->AddIndirectObject(pStream);
pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
}
CPDF_Dictionary * pStreamDict = pStream->GetDict();
if (!pStreamDict)
{
pStreamDict = new CPDF_Dictionary;
pStream->InitStream(NULL, 0, pStreamDict);
}
if (pStreamDict)
{
CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources");
if (!pStreamResList)
{
pStreamResList = new CPDF_Dictionary();
pStreamDict->SetAt("Resources", pStreamResList);
}
if (pStreamResList)
{
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font");
if (!pStreamResFontList)
{
pStreamResFontList = new CPDF_Dictionary;
FX_INT32 objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
pStreamResList->SetAtReference("Font", m_pDocument, objnum);
}
if (!pStreamResFontList->KeyExist(sAlias))
pStreamResFontList->SetAtReference(sAlias, m_pDocument, pFont->GetFontDict());
}
}
}
示例5: v_Init
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
if (pObj->GetType() != PDFOBJ_STREAM) {
return FALSE;
}
CPDF_Stream* pStream = (CPDF_Stream*)pObj;
CPDF_Dictionary* pDict = pStream->GetDict();
CPDF_Array* pSize = pDict->GetArray(FX_BSTRC("Size"));
CPDF_Array* pEncode = pDict->GetArray(FX_BSTRC("Encode"));
CPDF_Array* pDecode = pDict->GetArray(FX_BSTRC("Decode"));
m_nBitsPerSample = pDict->GetInteger(FX_BSTRC("BitsPerSample"));
if (m_nBitsPerSample > 32) {
return FALSE;
}
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
m_pSampleStream = new CPDF_StreamAcc;
m_pSampleStream->LoadAllData(pStream, FALSE);
m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs);
FX_SAFE_DWORD nTotalSampleBits = 1;
for (int i = 0; i < m_nInputs; i++) {
m_pEncodeInfo[i].sizes = pSize ? pSize->GetInteger(i) : 0;
if (!pSize && i == 0) {
m_pEncodeInfo[i].sizes = pDict->GetInteger(FX_BSTRC("Size"));
}
nTotalSampleBits *= m_pEncodeInfo[i].sizes;
if (pEncode) {
m_pEncodeInfo[i].encode_min = pEncode->GetFloat(i * 2);
m_pEncodeInfo[i].encode_max = pEncode->GetFloat(i * 2 + 1);
} else {
m_pEncodeInfo[i].encode_min = 0;
if (m_pEncodeInfo[i].sizes == 1) {
m_pEncodeInfo[i].encode_max = 1;
} else {
m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes - 1;
}
}
}
nTotalSampleBits *= m_nBitsPerSample;
nTotalSampleBits *= m_nOutputs;
FX_SAFE_DWORD nTotalSampleBytes = nTotalSampleBits;
nTotalSampleBytes += 7;
nTotalSampleBytes /= 8;
if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) {
return FALSE;
}
m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs);
for (int i = 0; i < m_nOutputs; i++) {
if (pDecode) {
m_pDecodeInfo[i].decode_min = pDecode->GetFloat(2 * i);
m_pDecodeInfo[i].decode_max = pDecode->GetFloat(2 * i + 1);
} else {
m_pDecodeInfo[i].decode_min = m_pRanges[i * 2];
m_pDecodeInfo[i].decode_max = m_pRanges[i * 2 + 1];
}
}
return TRUE;
}
示例6: switch
FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
CPDF_Document* pDoc,
ObjectNumberMap* pObjNumberMap) {
switch (pObj->GetType()) {
case CPDF_Object::REFERENCE: {
CPDF_Reference* pReference = pObj->AsReference();
uint32_t newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference);
if (newobjnum == 0)
return FALSE;
pReference->SetRef(pDoc, newobjnum);
break;
}
case CPDF_Object::DICTIONARY: {
CPDF_Dictionary* pDict = pObj->AsDictionary();
auto it = pDict->begin();
while (it != pDict->end()) {
const CFX_ByteString& key = it->first;
CPDF_Object* pNextObj = it->second;
++it;
if (key == "Parent" || key == "Prev" || key == "First")
continue;
if (!pNextObj)
return FALSE;
if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
pDict->RemoveFor(key);
}
break;
}
case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
for (size_t i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pNextObj = pArray->GetObjectAt(i);
if (!pNextObj)
return FALSE;
if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
return FALSE;
}
break;
}
case CPDF_Object::STREAM: {
CPDF_Stream* pStream = pObj->AsStream();
CPDF_Dictionary* pDict = pStream->GetDict();
if (pDict) {
if (!UpdateReference(pDict, pDoc, pObjNumberMap))
return FALSE;
} else {
return FALSE;
}
break;
}
default:
break;
}
return TRUE;
}
示例7: CPDF_Stream
void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
const CPDF_Rect& rcBBox,
const CFX_Matrix& matrix,
const CFX_ByteString& sContents,
const CFX_ByteString& sAPState) {
CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP");
if (!pAPDict) {
pAPDict = new CPDF_Dictionary;
m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
}
CPDF_Stream* pStream = nullptr;
CPDF_Dictionary* pParentDict = nullptr;
if (sAPState.IsEmpty()) {
pParentDict = pAPDict;
pStream = pAPDict->GetStreamBy(sAPType);
} else {
CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictBy(sAPType);
if (!pAPTypeDict) {
pAPTypeDict = new CPDF_Dictionary;
pAPDict->SetAt(sAPType, pAPTypeDict);
}
pParentDict = pAPTypeDict;
pStream = pAPTypeDict->GetStreamBy(sAPState);
}
if (!pStream) {
pStream = new CPDF_Stream(nullptr, 0, nullptr);
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
int32_t objnum = pDoc->AddIndirectObject(pStream);
pParentDict->SetAtReference(sAPType, pDoc, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStreamDict->SetAtName("Type", "XObject");
pStreamDict->SetAtName("Subtype", "Form");
pStreamDict->SetAtInteger("FormType", 1);
pStream->InitStream(nullptr, 0, pStreamDict);
}
if (pStreamDict) {
pStreamDict->SetAtMatrix("Matrix", matrix);
pStreamDict->SetAtRect("BBox", rcBBox);
}
pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE,
FALSE);
}
示例8: v_Init
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
CPDF_Stream* pStream = pObj->AsStream();
if (!pStream)
return false;
CPDF_Dictionary* pDict = pStream->GetDict();
CPDF_Array* pSize = pDict->GetArrayBy("Size");
CPDF_Array* pEncode = pDict->GetArrayBy("Encode");
CPDF_Array* pDecode = pDict->GetArrayBy("Decode");
m_nBitsPerSample = pDict->GetIntegerBy("BitsPerSample");
if (!IsValidBitsPerSample(m_nBitsPerSample))
return FALSE;
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
m_pSampleStream.reset(new CPDF_StreamAcc);
m_pSampleStream->LoadAllData(pStream, FALSE);
FX_SAFE_UINT32 nTotalSampleBits = 1;
m_EncodeInfo.resize(m_nInputs);
for (uint32_t i = 0; i < m_nInputs; i++) {
m_EncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0;
if (!pSize && i == 0)
m_EncodeInfo[i].sizes = pDict->GetIntegerBy("Size");
nTotalSampleBits *= m_EncodeInfo[i].sizes;
if (pEncode) {
m_EncodeInfo[i].encode_min = pEncode->GetFloatAt(i * 2);
m_EncodeInfo[i].encode_max = pEncode->GetFloatAt(i * 2 + 1);
} else {
m_EncodeInfo[i].encode_min = 0;
m_EncodeInfo[i].encode_max =
m_EncodeInfo[i].sizes == 1 ? 1 : (FX_FLOAT)m_EncodeInfo[i].sizes - 1;
}
}
nTotalSampleBits *= m_nBitsPerSample;
nTotalSampleBits *= m_nOutputs;
FX_SAFE_UINT32 nTotalSampleBytes = nTotalSampleBits;
nTotalSampleBytes += 7;
nTotalSampleBytes /= 8;
if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) {
return FALSE;
}
m_DecodeInfo.resize(m_nOutputs);
for (uint32_t i = 0; i < m_nOutputs; i++) {
if (pDecode) {
m_DecodeInfo[i].decode_min = pDecode->GetFloatAt(2 * i);
m_DecodeInfo[i].decode_max = pDecode->GetFloatAt(2 * i + 1);
} else {
m_DecodeInfo[i].decode_min = m_pRanges[i * 2];
m_DecodeInfo[i].decode_max = m_pRanges[i * 2 + 1];
}
}
return TRUE;
}
示例9: IsFormStream
FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
auto it = m_IndirectObjs.find(objnum);
if (it != m_IndirectObjs.end()) {
CPDF_Stream* pStream = it->second->AsStream();
bForm = pStream && pStream->GetDict()->GetString("Subtype") == "Form";
return TRUE;
}
if (!m_pParser) {
bForm = FALSE;
return TRUE;
}
return m_pParser->IsFormStream(objnum, bForm);
}
示例10: CPDF_Stream
void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
const CFX_ByteString& sAlias) {
if (!pFont)
return;
CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP");
if (!pAPDict) {
pAPDict = new CPDF_Dictionary;
m_pAnnotDict->SetAt("AP", pAPDict);
}
// to avoid checkbox and radiobutton
CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType);
if (ToDictionary(pObject))
return;
CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType);
if (!pStream) {
pStream = new CPDF_Stream(nullptr, 0, nullptr);
int32_t objnum = m_pDocument->AddIndirectObject(pStream);
pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStream->InitStream(nullptr, 0, pStreamDict);
}
if (pStreamDict) {
CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
if (!pStreamResList) {
pStreamResList = new CPDF_Dictionary();
pStreamDict->SetAt("Resources", pStreamResList);
}
if (pStreamResList) {
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
if (!pStreamResFontList) {
pStreamResFontList = new CPDF_Dictionary;
int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
pStreamResList->SetAtReference("Font", m_pDocument, objnum);
}
if (!pStreamResFontList->KeyExist(sAlias))
pStreamResFontList->SetAtReference(sAlias, m_pDocument,
pFont->GetFontDict());
}
}
}
示例11: GetString
void CPDF_StreamContentParser::Handle_ExecuteXObject() {
CFX_ByteString name = GetString(0);
if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() &&
m_pLastImage->GetStream()->GetObjNum()) {
AddImage(nullptr, m_pLastImage, FALSE);
return;
}
if (m_Options.m_bTextOnly) {
if (!m_pResources)
return;
CPDF_Dictionary* pList = m_pResources->GetDict("XObject");
if (!pList && m_pPageResources && m_pResources != m_pPageResources)
pList = m_pPageResources->GetDict("XObject");
if (!pList)
return;
CPDF_Reference* pRes = ToReference(pList->GetElement(name));
if (!pRes)
return;
FX_BOOL bForm;
if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm)
return;
}
CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name));
if (!pXObject) {
m_bResourceMissing = TRUE;
return;
}
CFX_ByteStringC type = pXObject->GetDict()
? pXObject->GetDict()->GetConstString("Subtype")
: CFX_ByteStringC();
if (type == "Image") {
if (m_Options.m_bTextOnly) {
return;
}
CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE);
m_LastImageName = name;
m_pLastImage = pObj->m_pImage;
if (!m_pObjectList->m_bHasImageMask)
m_pObjectList->m_bHasImageMask = m_pLastImage->IsMask();
} else if (type == "Form") {
AddForm(pXObject);
} else {
return;
}
}
示例12: ProcessImage
void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf,
CPDF_ImageObject* pImageObj) {
if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) ||
(pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) {
return;
}
buf << "q " << pImageObj->m_Matrix << " cm ";
CPDF_Image* pImage = pImageObj->GetImage();
if (!pImage->IsInline()) {
CPDF_Stream* pStream = pImage->GetStream();
uint32_t dwSavedObjNum = pStream->GetObjNum();
CFX_ByteString name = RealizeResource(pStream, "XObject");
if (dwSavedObjNum == 0) {
pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream));
}
buf << "/" << PDF_NameEncode(name) << " Do Q\n";
}
}
示例13: FPDFPage_InsertClipPath
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
FPDF_CLIPPATH clipPath) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
CPDF_Dictionary* pPageDict = pPage->GetDict();
CPDF_Object* pContentObj = GetPageContent(pPageDict);
if (!pContentObj)
return;
std::ostringstream strClip;
CPDF_ClipPath* pClipPath = CPDFClipPathFromFPDFClipPath(clipPath);
for (size_t i = 0; i < pClipPath->GetPathCount(); ++i) {
CPDF_Path path = pClipPath->GetPath(i);
if (path.GetPoints().empty()) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (pClipPath->GetClipType(i) == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Document* pDoc = pPage->GetDocument();
if (!pDoc)
return;
CPDF_Stream* pStream =
pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDoc->New<CPDF_Dictionary>());
pStream->SetDataFromStringstream(&strClip);
if (CPDF_Array* pArray = ToArray(pContentObj)) {
pArray->InsertAt(0, pStream->MakeReference(pDoc));
} else if (pContentObj->IsStream() && !pContentObj->IsInline()) {
CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->Add(pStream->MakeReference(pDoc));
pContentArray->Add(pContentObj->MakeReference(pDoc));
pPageDict->SetFor(pdfium::page_object::kContents,
pContentArray->MakeReference(pDoc));
}
}
示例14: CPDF_Stream
void CPDF_PageContentGenerate::ProcessForm(CFX_ByteTextBuf& buf,
const uint8_t* data,
FX_DWORD size,
CFX_Matrix& matrix) {
if (!data || !size) {
return;
}
CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL);
CPDF_Dictionary* pFormDict = CPDF_Dictionary::Create();
pFormDict->SetAtName("Type", "XObject");
pFormDict->SetAtName("Subtype", "Form");
CFX_FloatRect bbox = m_pPage->GetPageBBox();
matrix.TransformRect(bbox);
pFormDict->SetAtRect("BBox", bbox);
pStream->InitStream((uint8_t*)data, size, pFormDict);
buf << "q " << matrix << " cm ";
CFX_ByteString name = RealizeResource(pStream, "XObject");
buf << "/" << PDF_NameEncode(name) << " Do Q\n";
}
示例15: GetFormStream
static CPDF_Stream* GetFormStream(CPDF_Document* pDoc, CPDF_Object* pResObj)
{
if (pResObj->GetType() != PDFOBJ_REFERENCE) {
return NULL;
}
CPDF_Reference* pRef = (CPDF_Reference*)pResObj;
FX_BOOL bForm;
if (pDoc->IsFormStream(pRef->GetRefObjNum(), bForm) && !bForm) {
return NULL;
}
pResObj = pRef->GetDirect();
if (pResObj->GetType() != PDFOBJ_STREAM) {
return NULL;
}
CPDF_Stream* pXObject = (CPDF_Stream*)pResObj;
if (pXObject->GetDict()->GetString(FX_BSTRC("Subtype")) != FX_BSTRC("Form")) {
return NULL;
}
return pXObject;
}