本文整理汇总了C++中CPDF_Object::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Object::Clone方法的具体用法?C++ CPDF_Object::Clone怎么用?C++ CPDF_Object::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Object
的用法示例。
在下文中一共展示了CPDF_Object::Clone方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Clone
CPDF_Object* CPDF_Array::Clone(FX_BOOL bDirect) const {
CPDF_Array* pCopy = new CPDF_Array();
for (size_t i = 0; i < GetCount(); i++) {
CPDF_Object* value = m_Objects.at(i);
pCopy->m_Objects.push_back(value->Clone(bDirect));
}
return pCopy;
}
示例2: FPDFAPI_FlatPageAttr
void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, FX_BSTR name)
{
if (pPageDict->KeyExist(name)) {
return;
}
CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name);
if (pObj) {
pPageDict->SetAt(name, pObj->Clone());
}
}
示例3: 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;
}
示例4: EndImageDict
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: Handle_BeginImage
void CPDF_StreamContentParser::Handle_BeginImage()
{
FX_FILESIZE savePos = m_pSyntax->GetPos();
CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::Keyword) {
CFX_ByteString bsKeyword(m_pSyntax->GetWordBuf(), m_pSyntax->GetWordSize());
if (bsKeyword != FX_BSTRC("ID")) {
m_pSyntax->SetPos(savePos);
pDict->Release();
return;
}
}
if (type != CPDF_StreamParser::Name) {
break;
}
CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, m_pSyntax->GetWordSize() - 1);
CPDF_Object* pObj = m_pSyntax->ReadNextObject();
if (!key.IsEmpty()) {
pDict->SetAt(key, pObj, m_pDocument);
} else if (pObj) {
pObj->Release();
}
}
_PDF_ReplaceAbbr(pDict);
CPDF_Object* pCSObj = NULL;
if (pDict->KeyExist(FX_BSTRC("ColorSpace"))) {
pCSObj = pDict->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 && !pCSObj->GetObjNum()) {
pCSObj = pCSObj->Clone();
pDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj, m_pDocument);
}
}
}
}
CPDF_Stream* pStream = m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj, m_Options.m_bDecodeInlineImage);
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::EndOfData) {
break;
}
if (type != CPDF_StreamParser::Keyword) {
continue;
}
if (m_pSyntax->GetWordSize() == 2 && m_pSyntax->GetWordBuf()[0] == 'E' &&
m_pSyntax->GetWordBuf()[1] == 'I') {
break;
}
}
if (m_Options.m_bTextOnly) {
if (pStream) {
pStream->Release();
} else {
pDict->Release();
}
return;
}
pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image"));
CPDF_ImageObject *pImgObj = AddImage(pStream, NULL, TRUE);
if (!pImgObj) {
if (pStream) {
pStream->Release();
} else {
pDict->Release();
}
}
}
示例6: AddTerminalField
CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
if (!pFieldDict->KeyExist("FT")) {
// Key "FT" is required for terminal fields, it is also inheritable.
CPDF_Dictionary* pParentDict = pFieldDict->GetDictFor("Parent");
if (!pParentDict || !pParentDict->KeyExist("FT"))
return nullptr;
}
CPDF_Dictionary* pDict = pFieldDict;
CFX_WideString csWName = FPDF_GetFullName(pFieldDict);
if (csWName.IsEmpty())
return nullptr;
CPDF_FormField* pField = nullptr;
pField = m_pFieldTree->GetField(csWName);
if (!pField) {
CPDF_Dictionary* pParent = pFieldDict;
if (!pFieldDict->KeyExist("T") &&
pFieldDict->GetStringFor("Subtype") == "Widget") {
pParent = pFieldDict->GetDictFor("Parent");
if (!pParent)
pParent = pFieldDict;
}
if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) {
if (pFieldDict->KeyExist("FT")) {
CPDF_Object* pFTValue = pFieldDict->GetDirectObjectFor("FT");
if (pFTValue)
pParent->SetFor("FT", pFTValue->Clone());
}
if (pFieldDict->KeyExist("Ff")) {
CPDF_Object* pFfValue = pFieldDict->GetDirectObjectFor("Ff");
if (pFfValue)
pParent->SetFor("Ff", pFfValue->Clone());
}
}
pField = new CPDF_FormField(this, pParent);
CPDF_Object* pTObj = pDict->GetObjectFor("T");
if (ToReference(pTObj)) {
std::unique_ptr<CPDF_Object> pClone = pTObj->CloneDirectObject();
if (pClone)
pDict->SetFor("T", std::move(pClone));
else
pDict->SetNewFor<CPDF_Name>("T", "");
}
m_pFieldTree->SetField(csWName, pField);
}
CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids");
if (pKids) {
for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid)
continue;
if (pKid->GetStringFor("Subtype") != "Widget")
continue;
AddControl(pField, pKid);
}
} else {
if (pFieldDict->GetStringFor("Subtype") == "Widget")
AddControl(pField, pFieldDict);
}
return pField;
}
示例7: AddTerminalField
CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
if (!pFieldDict->KeyExist("T"))
return nullptr;
CPDF_Dictionary* pDict = pFieldDict;
CFX_WideString csWName = FPDF_GetFullName(pFieldDict);
if (csWName.IsEmpty())
return nullptr;
CPDF_FormField* pField = nullptr;
pField = m_pFieldTree->GetField(csWName);
if (!pField) {
CPDF_Dictionary* pParent = pFieldDict;
if (!pFieldDict->KeyExist("T") &&
pFieldDict->GetStringBy("Subtype") == "Widget") {
pParent = pFieldDict->GetDictBy("Parent");
if (!pParent)
pParent = pFieldDict;
}
if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) {
if (pFieldDict->KeyExist("FT")) {
CPDF_Object* pFTValue = pFieldDict->GetDirectObjectBy("FT");
if (pFTValue)
pParent->SetAt("FT", pFTValue->Clone());
}
if (pFieldDict->KeyExist("Ff")) {
CPDF_Object* pFfValue = pFieldDict->GetDirectObjectBy("Ff");
if (pFfValue)
pParent->SetAt("Ff", pFfValue->Clone());
}
}
pField = new CPDF_FormField(this, pParent);
CPDF_Object* pTObj = pDict->GetObjectBy("T");
if (ToReference(pTObj)) {
CPDF_Object* pClone = pTObj->CloneDirectObject();
if (pClone)
pDict->SetAt("T", pClone);
else
pDict->SetAtName("T", "");
}
m_pFieldTree->SetField(csWName, pField);
}
CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
if (!pKids) {
if (pFieldDict->GetStringBy("Subtype") == "Widget")
AddControl(pField, pFieldDict);
} else {
for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid)
continue;
if (pKid->GetStringBy("Subtype") != "Widget")
continue;
AddControl(pField, pKid);
}
}
return pField;
}
示例8: ResetField
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: ExportPage
FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc,
CFX_WordArray* nPageNum,
CPDF_Document* pDestPDFDoc,
int nIndex) {
int curpage = nIndex;
nonstd::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap);
for (int i = 0; i < nPageNum->GetSize(); ++i) {
CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage);
CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(nPageNum->GetAt(i) - 1);
if (!pSrcPageDict || !pCurPageDict)
return FALSE;
// Clone the page dictionary///////////
FX_POSITION SrcPos = pSrcPageDict->GetStartPos();
while (SrcPos) {
CFX_ByteString cbSrcKeyStr;
CPDF_Object* pObj = pSrcPageDict->GetNextElement(SrcPos, cbSrcKeyStr);
if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) {
if (pCurPageDict->KeyExist(cbSrcKeyStr))
pCurPageDict->RemoveAt(cbSrcKeyStr);
pCurPageDict->SetAt(cbSrcKeyStr, pObj->Clone());
}
}
// inheritable item///////////////////////
CPDF_Object* pInheritable = nullptr;
// 1 MediaBox //required
if (!pCurPageDict->KeyExist("MediaBox")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "MediaBox");
if (!pInheritable) {
// Search the "CropBox" from source page dictionary,
// if not exists,we take the letter size.
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
if (pInheritable) {
pCurPageDict->SetAt("MediaBox", pInheritable->Clone());
} else {
// Make the default size to be letter size (8.5'x11')
CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber(0);
pArray->AddNumber(0);
pArray->AddNumber(612);
pArray->AddNumber(792);
pCurPageDict->SetAt("MediaBox", pArray);
}
} else {
pCurPageDict->SetAt("MediaBox", pInheritable->Clone());
}
}
// 2 Resources //required
if (!pCurPageDict->KeyExist("Resources")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources");
if (!pInheritable)
return FALSE;
pCurPageDict->SetAt("Resources", pInheritable->Clone());
}
// 3 CropBox //Optional
if (!pCurPageDict->KeyExist("CropBox")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
if (pInheritable)
pCurPageDict->SetAt("CropBox", pInheritable->Clone());
}
// 4 Rotate //Optional
if (!pCurPageDict->KeyExist("Rotate")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate");
if (pInheritable)
pCurPageDict->SetAt("Rotate", pInheritable->Clone());
}
/////////////////////////////////////////////
// Update the reference
FX_DWORD dwOldPageObj = pSrcPageDict->GetObjNum();
FX_DWORD dwNewPageObj = pCurPageDict->GetObjNum();
(*pObjNumberMap)[dwOldPageObj] = dwNewPageObj;
UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get());
++curpage;
}
return TRUE;
}
示例10: ResetField
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
int iCount = CountControls();
if (iCount) {
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++) {
CPDF_FormControl* pControl = GetControl(i);
FX_BOOL bChecked = pControl->IsDefaultChecked();
CheckControl(i, bChecked, FALSE);
}
}
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
} break;
case CPDF_FormField::ComboBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0) {
csValue = GetOptionLabel(iIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue);
if (iRet < 0) {
return FALSE;
}
}
SetItemSelection(iIndex, TRUE);
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
} break;
case CPDF_FormField::ListBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0) {
csValue = GetOptionLabel(iIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue);
if (iRet < 0) {
return FALSE;
}
}
SetItemSelection(iIndex, TRUE);
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterSelectionChange(this);
}
} 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 && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue);
if (iRet < 0) {
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 && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
m_pForm->m_bUpdated = TRUE;
//.........这里部分代码省略.........
示例11: ExportToFDF
CFDF_Document* CPDF_InterForm::ExportToFDF(
const CFX_WideStringC& pdf_path,
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bSimpleFileSpec) const {
CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
if (pDoc == NULL) {
return NULL;
}
CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF");
if (!pdf_path.IsEmpty()) {
if (bSimpleFileSpec) {
CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path);
pMainDict->SetAtString(FX_BSTRC("F"),
CFX_ByteString::FromUnicode(wsFilePath));
pMainDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(wsFilePath));
} else {
CPDF_FileSpec filespec;
filespec.SetFileName(pdf_path);
pMainDict->SetAt("F", static_cast<CPDF_Object*>(filespec));
}
}
CPDF_Array* pFields = CPDF_Array::Create();
if (pFields == NULL) {
return NULL;
}
pMainDict->SetAt("Fields", pFields);
int nCount = m_pFieldTree->m_Root.CountFields();
for (int i = 0; i < nCount; i++) {
CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) {
continue;
}
FX_DWORD dwFlags = pField->GetFieldFlags();
if (dwFlags & 0x04)
continue;
auto it = std::find(fields.begin(), fields.end(), pField);
if (bIncludeOrExclude == (it != fields.end())) {
if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty())
continue;
CFX_WideString fullname = GetFullName(pField->GetFieldDict());
CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create();
if (!pFieldDict)
return nullptr;
CPDF_String* pString = CPDF_String::Create(fullname);
if (!pString) {
pFieldDict->Release();
return nullptr;
}
pFieldDict->SetAt("T", pString);
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->SetAtString("V", csBExport);
else
pFieldDict->SetAtName("V", csBExport);
} else {
CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
if (pV)
pFieldDict->SetAt("V", pV->Clone(TRUE));
}
pFields->Add(pFieldDict);
}
}
return pDoc;
}
示例12: AddTerminalField
CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
if (!pFieldDict->KeyExist(FX_BSTRC("T"))) {
return NULL;
}
CPDF_Dictionary* pDict = pFieldDict;
CFX_WideString csWName = GetFullName(pFieldDict);
if (csWName.IsEmpty()) {
return NULL;
}
CPDF_FormField* pField = NULL;
pField = m_pFieldTree->GetField(csWName);
if (pField == NULL) {
CPDF_Dictionary* pParent = pFieldDict;
if (!pFieldDict->KeyExist(FX_BSTRC("T")) &&
pFieldDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget")) {
pParent = pFieldDict->GetDict(FX_BSTRC("Parent"));
if (!pParent) {
pParent = pFieldDict;
}
}
if (pParent && pParent != pFieldDict &&
!pParent->KeyExist(FX_BSTRC("FT"))) {
if (pFieldDict->KeyExist(FX_BSTRC("FT"))) {
CPDF_Object* pFTValue = pFieldDict->GetElementValue(FX_BSTRC("FT"));
if (pFTValue) {
pParent->SetAt(FX_BSTRC("FT"), pFTValue->Clone());
}
}
if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) {
CPDF_Object* pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff"));
if (pFfValue) {
pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone());
}
}
}
pField = new CPDF_FormField(this, pParent);
CPDF_Object* pTObj = pDict->GetElement("T");
if (ToReference(pTObj)) {
CPDF_Object* pClone = pTObj->Clone(TRUE);
if (pClone)
pDict->SetAt("T", pClone);
else
pDict->SetAtName("T", "");
}
m_pFieldTree->SetField(csWName, pField);
}
CPDF_Array* pKids = pFieldDict->GetArray("Kids");
if (pKids == NULL) {
if (pFieldDict->GetString("Subtype") == "Widget") {
AddControl(pField, pFieldDict);
}
} else {
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDict(i);
if (pKid == NULL) {
continue;
}
if (pKid->GetString("Subtype") != "Widget") {
continue;
}
AddControl(pField, pKid);
}
}
return pField;
}
示例13: ExportPage
FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc,
std::vector<uint16_t>* pPageNums,
CPDF_Document* pDestPDFDoc,
int nIndex) {
int curpage = nIndex;
std::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap);
int nSize = pdfium::CollectionSize<int>(*pPageNums);
for (int i = 0; i < nSize; ++i) {
CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage);
CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(pPageNums->at(i) - 1);
if (!pSrcPageDict || !pCurPageDict)
return FALSE;
// Clone the page dictionary
for (const auto& it : *pSrcPageDict) {
const CFX_ByteString& cbSrcKeyStr = it.first;
CPDF_Object* pObj = it.second;
if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) {
if (pCurPageDict->KeyExist(cbSrcKeyStr))
pCurPageDict->RemoveFor(cbSrcKeyStr);
pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone());
}
}
// inheritable item
CPDF_Object* pInheritable = nullptr;
// 1 MediaBox //required
if (!pCurPageDict->KeyExist("MediaBox")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "MediaBox");
if (!pInheritable) {
// Search the "CropBox" from source page dictionary,
// if not exists,we take the letter size.
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
if (pInheritable) {
pCurPageDict->SetFor("MediaBox", pInheritable->Clone());
} else {
// Make the default size to be letter size (8.5'x11')
CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber(0);
pArray->AddNumber(0);
pArray->AddNumber(612);
pArray->AddNumber(792);
pCurPageDict->SetFor("MediaBox", pArray);
}
} else {
pCurPageDict->SetFor("MediaBox", pInheritable->Clone());
}
}
// 2 Resources //required
if (!pCurPageDict->KeyExist("Resources")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources");
if (!pInheritable)
return FALSE;
pCurPageDict->SetFor("Resources", pInheritable->Clone());
}
// 3 CropBox //Optional
if (!pCurPageDict->KeyExist("CropBox")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
if (pInheritable)
pCurPageDict->SetFor("CropBox", pInheritable->Clone());
}
// 4 Rotate //Optional
if (!pCurPageDict->KeyExist("Rotate")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate");
if (pInheritable)
pCurPageDict->SetFor("Rotate", pInheritable->Clone());
}
// Update the reference
uint32_t dwOldPageObj = pSrcPageDict->GetObjNum();
uint32_t dwNewPageObj = pCurPageDict->GetObjNum();
(*pObjNumberMap)[dwOldPageObj] = dwNewPageObj;
UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get());
++curpage;
}
return TRUE;
}