本文整理汇总了C++中CPDF_Object类的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Object类的具体用法?C++ CPDF_Object怎么用?C++ CPDF_Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPDF_Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetElement
CPDF_Object* CPDF_Dictionary::GetElementValue(
const CFX_ByteStringC& key) const {
CPDF_Object* p = GetElement(key);
return p ? p->GetDirect() : nullptr;
}
示例2: GetElementValue
CPDF_Object* CPDF_Dictionary::GetElementValue(FX_BSTR key) const
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
return p ? p->GetDirect() : NULL;
}
示例3: FPDFPage_InsertClipPath
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
FPDF_CLIPPATH clipPath) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
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;
CFX_ByteTextBuf strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
FX_DWORD i;
for (i = 0; i < pClipPath->GetPathCount(); i++) {
CPDF_Path path = pClipPath->GetPath(i);
int iClipType = pClipPath->GetClipType(i);
if (path.GetPointCount() == 0) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (iClipType == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Dictionary* pDic = new CPDF_Dictionary;
CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return;
pDoc->AddIndirectObject(pStream);
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);
} 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);
} else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pPageDic->SetAtReference("Contents", pDoc,
pDoc->AddIndirectObject(pContentArray));
}
}
}
}
示例4: FXSYS_memcmp32
void CPDF_StreamContentParser::EndImageDict()
{
if (m_StringBuf.GetSize() != m_LastImageDict.GetSize() ||
FXSYS_memcmp32(m_StringBuf.GetBuffer(), m_LastImageDict.GetBuffer(), m_StringBuf.GetSize())) {
m_WordState = 0;
StartDict();
InputData(m_StringBuf.GetBuffer(), m_StringBuf.GetSize());
Finish();
m_bSameLastDict = FALSE;
if (m_pLastImageDict && m_bReleaseLastDict) {
m_pLastImageDict->Release();
m_pLastImageDict = NULL;
}
if (!m_ObjectSize) {
m_InlineImageState = 0;
return;
}
m_pLastImageDict = (CPDF_Dictionary*)m_pObjectStack[--m_ObjectSize];
m_bReleaseLastDict = !m_pObjectState[m_ObjectSize];
m_pObjectState[m_ObjectSize] = FALSE;
_PDF_ReplaceAbbr(m_pLastImageDict);
m_LastImageDict.TakeOver(m_StringBuf);
if (m_pLastImageDict->KeyExist(FX_BSTRC("ColorSpace"))) {
CPDF_Object* pCSObj = m_pLastImageDict->GetElementValue(FX_BSTRC("ColorSpace"));
if (pCSObj->GetType() == PDFOBJ_NAME) {
CFX_ByteString name = pCSObj->GetString();
if (name != FX_BSTRC("DeviceRGB") && name != FX_BSTRC("DeviceGray") && name != FX_BSTRC("DeviceCMYK")) {
pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name);
if (pCSObj) {
if (!pCSObj->GetObjNum()) {
pCSObj = pCSObj->Clone();
}
m_pLastImageDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj, m_pDocument);
}
}
}
}
} else {
m_bSameLastDict = TRUE;
}
m_ImageSrcBuf.Clear();
if (m_pLastCloneImageDict) {
m_pLastCloneImageDict->Release();
}
m_pLastCloneImageDict = (CPDF_Dictionary*)m_pLastImageDict->Clone();
if (m_pLastCloneImageDict->KeyExist(FX_BSTRC("Filter"))) {
m_WordState = 10;
m_InlineImageState = 0;
} else {
int width = m_pLastCloneImageDict->GetInteger(FX_BSTRC("Width"));
int height = m_pLastCloneImageDict->GetInteger(FX_BSTRC("Height"));
int OrigSize = 0;
CPDF_Object* pCSObj = m_pLastCloneImageDict->GetElementValue(FX_BSTRC("ColorSpace"));
if (pCSObj != NULL) {
int bpc = m_pLastCloneImageDict->GetInteger(FX_BSTRC("BitsPerComponent"));
int nComponents = 1;
CPDF_ColorSpace* pCS = m_pDocument->LoadColorSpace(pCSObj);
if (pCS == NULL) {
nComponents = 3;
} else {
nComponents = pCS->CountComponents();
m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
}
int pitch = (width * bpc * nComponents + 7) / 8;
OrigSize = pitch * height;
} else {
OrigSize = ((width + 7) / 8) * height;
}
m_ImageSrcBuf.AppendBlock(NULL, OrigSize);
m_WordState = 11;
m_InlineImageState = 0;
}
}
示例5: GetObject
bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
PageNode* pPageNode,
DownloadHints* pHints) {
bool bExist = false;
std::unique_ptr<CPDF_Object> pPage = GetObject(dwPageNo, pHints, &bExist);
if (!bExist) {
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
if (!pPage) {
if (m_docStatus == PDF_DATAAVAIL_ERROR)
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
if (pPage->IsArray()) {
pPageNode->m_dwPageNo = dwPageNo;
pPageNode->m_type = PDF_PAGENODE_ARRAY;
return true;
}
if (!pPage->IsDictionary()) {
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
pPageNode->m_dwPageNo = dwPageNo;
CPDF_Dictionary* pDict = pPage->GetDict();
CFX_ByteString type = pDict->GetStringFor("Type");
if (type == "Pages") {
pPageNode->m_type = PDF_PAGENODE_PAGES;
CPDF_Object* pKids = pDict->GetObjectFor("Kids");
if (!pKids) {
m_docStatus = PDF_DATAAVAIL_PAGE;
return true;
}
switch (pKids->GetType()) {
case CPDF_Object::REFERENCE: {
CPDF_Reference* pKid = pKids->AsReference();
PageNode* pNode = new PageNode();
pPageNode->m_childNode.Add(pNode);
pNode->m_dwPageNo = pKid->GetRefObjNum();
} break;
case CPDF_Object::ARRAY: {
CPDF_Array* pKidsArray = pKids->AsArray();
for (size_t i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Reference* pKid = ToReference(pKidsArray->GetObjectAt(i));
if (!pKid)
continue;
PageNode* pNode = new PageNode();
pPageNode->m_childNode.Add(pNode);
pNode->m_dwPageNo = pKid->GetRefObjNum();
}
} break;
default:
break;
}
} else if (type == "Page") {
pPageNode->m_type = PDF_PAGENODE_PAGE;
} else {
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
return true;
}
示例6: FPDFPage_TransFormWithClip
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX* matrix, FS_RECTF* clipRect)
{
if(!page)
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_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
if(!pContentObj)
pContentObj = pPageDic->GetArray("Contents");
if(!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if(!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pEndStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pEndStream->SetData((FX_LPCBYTE)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = NULL;
if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pContentObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc,pEndStream);
}
else if(pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE)
{
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
if(pDirectObj != NULL)
{
if(pDirectObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pDirectObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc,pEndStream);
}
else if(pDirectObj->GetType() == PDFOBJ_STREAM)
{
pContentArray = FX_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->GetDict(FX_BSTRC("Resources"));
if(pRes)
{
CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern"));
if(pPattenDict)
{
FX_POSITION pos = pPattenDict->GetStartPos();
while(pos)
{
CPDF_Dictionary* pDict = NULL;
CFX_ByteString key;
CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
if(pObj->GetType() == PDFOBJ_REFERENCE)
pObj = pObj->GetDirect();
if(pObj->GetType() == PDFOBJ_DICTIONARY)
{
pDict = (CPDF_Dictionary*)pObj;
}
else if(pObj->GetType() == PDFOBJ_STREAM)
{
pDict = ((CPDF_Stream*)pObj)->GetDict();
}
else
continue;
CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
//.........这里部分代码省略.........
示例7: GetNextWord
CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray, FX_BOOL bInArray)
{
FX_BOOL bIsNumber;
GetNextWord(bIsNumber);
if (m_WordSize == 0) {
return NULL;
}
if (bIsNumber) {
m_WordBuffer[m_WordSize] = 0;
return CPDF_Number::Create(CFX_ByteStringC(m_WordBuffer, m_WordSize));
}
int first_char = m_WordBuffer[0];
if (first_char == '/') {
return CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
}
if (first_char == '(') {
return CPDF_String::Create(ReadString());
}
if (first_char == '<') {
if (m_WordSize == 1) {
return CPDF_String::Create(ReadHexString(), TRUE);
}
CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
while (1) {
GetNextWord(bIsNumber);
if (m_WordSize == 0) {
pDict->Release();
return NULL;
}
if (m_WordSize == 2 && m_WordBuffer[0] == '>') {
break;
}
if (m_WordBuffer[0] != '/') {
pDict->Release();
return NULL;
}
CFX_ByteString key = PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
CPDF_Object* pObj = ReadNextObject(TRUE);
if (pObj == NULL) {
if (pDict) {
pDict->Release();
}
return NULL;
}
if (!key.IsEmpty()) {
pDict->SetAt(key, pObj);
} else {
pObj->Release();
}
}
return pDict;
}
if (first_char == '[') {
if (!bAllowNestedArray && bInArray) {
return NULL;
}
CPDF_Array* pArray = CPDF_Array::Create();
while (1) {
CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, TRUE);
if (pObj == NULL) {
if (m_WordSize == 0 || m_WordBuffer[0] == ']') {
return pArray;
}
if (m_WordBuffer[0] == '[') {
continue;
}
} else {
pArray->Add(pObj);
}
}
}
if (m_WordSize == 4) {
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) {
return CPDF_Boolean::Create(TRUE);
}
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) {
return CPDF_Null::Create();
}
} else if (m_WordSize == 5) {
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') {
return CPDF_Boolean::Create(FALSE);
}
}
return NULL;
}
示例8: switch
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
int iCount = CountControls();
if (iCount) {
// TODO(weili): Check whether anything special needs to be done for
// unison field. Otherwise, merge these branches.
if (PDF_FormField_IsUnison(this)) {
for (int i = 0; i < iCount; i++) {
CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
}
} else {
for (int i = 0; i < iCount; i++) {
CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
}
}
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
} break;
case CPDF_FormField::ComboBox:
case CPDF_FormField::ListBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
if (bNotify && !NotifyListOrComboBoxBeforeChange(csValue))
return FALSE;
SetItemSelection(iIndex, TRUE);
if (bNotify)
NotifyListOrComboBoxAfterChange();
} break;
case CPDF_FormField::Text:
case CPDF_FormField::RichText:
case CPDF_FormField::File:
default: {
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV");
CFX_WideString csDValue;
if (pDV)
csDValue = pDV->GetUnicodeText();
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
CFX_WideString csValue;
if (pV)
csValue = pV->GetUnicodeText();
CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV");
if (!pRV && (csDValue == csValue))
return FALSE;
if (bNotify && !NotifyBeforeValueChange(csDValue))
return FALSE;
if (pDV) {
CPDF_Object* pClone = pDV->Clone();
if (!pClone)
return FALSE;
m_pDict->SetAt("V", pClone);
if (pRV) {
CPDF_Object* pCloneR = pDV->Clone();
m_pDict->SetAt("RV", pCloneR);
}
} else {
m_pDict->RemoveAt("V");
m_pDict->RemoveAt("RV");
}
if (bNotify)
NotifyAfterValueChange();
} break;
}
return TRUE;
}
示例9: FPDF_GetFieldAttr
CPDF_AAction CPDF_FormField::GetAdditionalAction() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA");
return CPDF_AAction(pObj ? pObj->GetDict() : nullptr);
}
示例10: FPDF_GetFieldAttr
CFX_WideString CPDF_FormField::GetRichTextString() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV");
return pObj ? pObj->GetUnicodeText() : L"";
}
示例11: ASSERT
FX_BOOL CPDF_FormField::SetItemSelection(int index,
FX_BOOL bSelected,
FX_BOOL bNotify) {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions())
return FALSE;
CFX_WideString opt_value = GetOptionValue(index);
if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value))
return FALSE;
if (bSelected) {
if (GetType() == ListBox) {
SelectOption(index, TRUE);
if (!(m_Flags & kFormListMultiSelect)) {
m_pDict->SetStringFor("V", PDF_EncodeText(opt_value));
} else {
CPDF_Array* pArray = new CPDF_Array;
for (int i = 0; i < CountOptions(); i++) {
if (i == index || IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddString(PDF_EncodeText(opt_value));
}
}
m_pDict->SetFor("V", pArray);
}
} else {
m_pDict->SetStringFor("V", PDF_EncodeText(opt_value));
CPDF_Array* pI = new CPDF_Array;
pI->AddInteger(index);
m_pDict->SetFor("I", pI);
}
} else {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (pValue) {
if (GetType() == ListBox) {
SelectOption(index, FALSE);
if (pValue->IsString()) {
if (pValue->GetUnicodeText() == opt_value)
m_pDict->RemoveFor("V");
} else if (pValue->IsArray()) {
std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray(
new CPDF_Array);
for (int i = 0; i < CountOptions(); i++) {
if (i != index && IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddString(PDF_EncodeText(opt_value));
}
}
if (pArray->GetCount() > 0)
m_pDict->SetFor("V", pArray.release()); // std::move someday
}
} else {
m_pDict->RemoveFor("V");
m_pDict->RemoveFor("I");
}
}
}
if (bNotify)
NotifyListOrComboBoxAfterChange();
return TRUE;
}
示例12: PDF_EncodeText
std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
const CFX_WideStringC& pdf_path,
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bSimpleFileSpec) const {
std::unique_ptr<CFDF_Document> pDoc = CFDF_Document::CreateNewDoc();
if (!pDoc)
return nullptr;
CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictFor("FDF");
if (!pdf_path.IsEmpty()) {
if (bSimpleFileSpec) {
CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
pMainDict->SetNewFor<CPDF_String>(
"F", CFX_ByteString::FromUnicode(wsFilePath), false);
pMainDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsFilePath),
false);
} else {
CPDF_FileSpec filespec(pDoc->GetByteStringPool());
filespec.SetFileName(pdf_path);
pMainDict->SetFor("F", pdfium::WrapUnique(filespec.GetObj()));
}
}
CPDF_Array* pFields = pMainDict->SetNewFor<CPDF_Array>("Fields");
size_t nCount = m_pFieldTree->m_Root.CountFields();
for (size_t i = 0; i < nCount; ++i) {
CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i);
if (!pField || pField->GetType() == CPDF_FormField::PushButton)
continue;
uint32_t dwFlags = pField->GetFieldFlags();
if (dwFlags & 0x04)
continue;
if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) {
if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringFor("V").IsEmpty())
continue;
CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict());
auto pFieldDict =
pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool());
pFieldDict->SetNewFor<CPDF_String>("T", fullname);
if (pField->GetType() == CPDF_FormField::CheckBox ||
pField->GetType() == CPDF_FormField::RadioButton) {
CFX_WideString csExport = pField->GetCheckValue(false);
CFX_ByteString csBExport = PDF_EncodeText(csExport);
CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
if (pOpt)
pFieldDict->SetNewFor<CPDF_String>("V", csBExport, false);
else
pFieldDict->SetNewFor<CPDF_Name>("V", csBExport);
} else {
CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
if (pV)
pFieldDict->SetFor("V", pV->CloneDirectObject());
}
pFields->Add(std::move(pFieldDict));
}
}
return pDoc;
}
示例13: ASSERT
FX_BOOL CPDF_FormField::SetItemSelection(int index,
FX_BOOL bSelected,
FX_BOOL bNotify) {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions())
return FALSE;
CFX_WideString opt_value = GetOptionValue(index);
if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value))
return FALSE;
if (bSelected) {
if (GetType() == ListBox) {
SelectOption(index, TRUE);
if (!(m_Flags & FORMLIST_MULTISELECT)) {
m_pDict->SetAtString("V", PDF_EncodeText(opt_value));
} else {
CPDF_Array* pArray = new CPDF_Array;
for (int i = 0; i < CountOptions(); i++) {
if (i == index || IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddString(PDF_EncodeText(opt_value));
}
}
m_pDict->SetAt("V", pArray);
}
} else {
m_pDict->SetAtString("V", PDF_EncodeText(opt_value));
CPDF_Array* pI = new CPDF_Array;
pI->AddInteger(index);
m_pDict->SetAt("I", pI);
}
} else {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (pValue) {
if (GetType() == ListBox) {
SelectOption(index, FALSE);
if (pValue->IsString()) {
if (pValue->GetUnicodeText() == opt_value)
m_pDict->RemoveAt("V");
} else if (pValue->IsArray()) {
CPDF_Array* pArray = new CPDF_Array;
for (int i = 0; i < CountOptions(); i++) {
if (i != index && IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddString(PDF_EncodeText(opt_value));
}
}
if (pArray->GetCount() < 1)
pArray->Release();
else
m_pDict->SetAt("V", pArray);
}
} else {
m_pDict->RemoveAt("V");
m_pDict->RemoveAt("I");
}
}
}
if (bNotify)
NotifyListOrComboBoxAfterChange();
return TRUE;
}
示例14: FPDFPage_InsertClipPath
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clipPath)
{
if(!page)
return;
CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
if(!pContentObj)
pContentObj = pPageDic->GetArray("Contents");
if(!pContentObj)
return;
CFX_ByteTextBuf strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
FX_DWORD i;
for (i = 0; i < pClipPath->GetPathCount(); i ++) {
CPDF_Path path = pClipPath->GetPath(i);
int iClipType = pClipPath->GetClipType(i);
if (path.GetPointCount() == 0) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (iClipType == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Dictionary* pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if(!pDoc)
return;
pDoc->AddIndirectObject(pStream);
CPDF_Array* pContentArray = NULL;
if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pContentObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
}
else if(pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE)
{
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
if(pDirectObj != NULL)
{
if(pDirectObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pDirectObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
}
else if(pDirectObj->GetType() == PDFOBJ_STREAM)
{
pContentArray = FX_NEW CPDF_Array();
pContentArray->AddReference(pDoc,pStream->GetObjNum());
pContentArray->AddReference(pDoc,pDirectObj->GetObjNum());
pPageDic->SetAtReference("Contents", pDoc, pDoc->AddIndirectObject(pContentArray));
}
}
}
}
示例15: ReadInlineStream
CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CPDF_Dictionary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode)
{
if (m_Pos == m_Size) {
return NULL;
}
if (PDF_CharType[m_pBuf[m_Pos]] == 'W') {
m_Pos ++;
}
CFX_ByteString Decoder;
CPDF_Dictionary* pParam = NULL;
CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter"));
if (pFilter == NULL) {
} else if (pFilter->GetType() == PDFOBJ_ARRAY) {
Decoder = ((CPDF_Array*)pFilter)->GetString(0);
CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms"));
if (pParams) {
pParam = pParams->GetDict(0);
}
} else {
Decoder = pFilter->GetString();
pParam = pDict->GetDict(FX_BSTRC("DecodeParms"));
}
FX_DWORD width = pDict->GetInteger(FX_BSTRC("Width"));
FX_DWORD height = pDict->GetInteger(FX_BSTRC("Height"));
FX_DWORD OrigSize = 0;
if (pCSObj != NULL) {
FX_DWORD bpc = pDict->GetInteger(FX_BSTRC("BitsPerComponent"));
FX_DWORD nComponents = 1;
CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj);
if (pCS == NULL) {
nComponents = 3;
} else {
nComponents = pCS->CountComponents();
pDoc->GetPageData()->ReleaseColorSpace(pCSObj);
}
FX_DWORD pitch = width;
if (bpc && pitch > INT_MAX / bpc) {
return NULL;
}
pitch *= bpc;
if (nComponents && pitch > INT_MAX / nComponents) {
return NULL;
}
pitch *= nComponents;
if (pitch > INT_MAX - 7) {
return NULL;
}
pitch += 7;
pitch /= 8;
OrigSize = pitch;
} else {
if (width > INT_MAX - 7) {
return NULL;
}
OrigSize = ((width + 7) / 8);
}
if (height && OrigSize > INT_MAX / height) {
return NULL;
}
OrigSize *= height;
uint8_t* pData = NULL;
FX_DWORD dwStreamSize;
if (Decoder.IsEmpty()) {
if (OrigSize > m_Size - m_Pos) {
OrigSize = m_Size - m_Pos;
}
pData = FX_Alloc(uint8_t, OrigSize);
FXSYS_memcpy(pData, m_pBuf + m_Pos, OrigSize);
dwStreamSize = OrigSize;
m_Pos += OrigSize;
} else {
FX_DWORD dwDestSize = OrigSize;
dwStreamSize = PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, Decoder, pParam,
pData, dwDestSize);
if ((int)dwStreamSize < 0) {
return NULL;
}
if (bDecode) {
m_Pos += dwStreamSize;
dwStreamSize = dwDestSize;
if (pFilter->GetType() == PDFOBJ_ARRAY) {
((CPDF_Array*)pFilter)->RemoveAt(0);
CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms"));
if (pParams) {
pParams->RemoveAt(0);
}
} else {
pDict->RemoveAt(FX_BSTRC("Filter"));
pDict->RemoveAt(FX_BSTRC("DecodeParms"));
}
} else {
if (pData) {
FX_Free(pData);
}
FX_DWORD dwSavePos = m_Pos;
m_Pos += dwStreamSize;
while (1) {
FX_DWORD dwPrevPos = m_Pos;
CPDF_StreamParser::SyntaxType type = ParseNextElement();
if (type == CPDF_StreamParser::EndOfData) {
//.........这里部分代码省略.........