本文整理汇总了C++中CPDF_Dictionary::ReplaceKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::ReplaceKey方法的具体用法?C++ CPDF_Dictionary::ReplaceKey怎么用?C++ CPDF_Dictionary::ReplaceKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::ReplaceKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PDF_ReplaceAbbr
void PDF_ReplaceAbbr(CPDF_Object* pObj) {
switch (pObj->GetType()) {
case PDFOBJ_DICTIONARY: {
CPDF_Dictionary* pDict = pObj->AsDictionary();
for (const auto& it : *pDict) {
CFX_ByteString key = it.first;
CPDF_Object* value = it.second;
CFX_ByteStringC fullname = PDF_FindFullName(
PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
if (!fullname.IsEmpty()) {
pDict->ReplaceKey(key, fullname);
key = fullname;
}
if (value->IsName()) {
CFX_ByteString name = value->GetString();
fullname = PDF_FindFullName(PDF_InlineValueAbbr,
FX_ArraySize(PDF_InlineValueAbbr), name);
if (!fullname.IsEmpty()) {
pDict->SetAtName(key, fullname);
}
} else {
PDF_ReplaceAbbr(value);
}
}
break;
}
case PDFOBJ_ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetElement(i);
if (pElement->IsName()) {
CFX_ByteString name = pElement->GetString();
CFX_ByteStringC fullname = PDF_FindFullName(
PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
if (!fullname.IsEmpty()) {
pArray->SetAt(i, new CPDF_Name(fullname));
}
} else {
PDF_ReplaceAbbr(pElement);
}
}
break;
}
}
}
示例2: SetOnStateName
void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn)
{
ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csValue = csOn;
if (csValue.IsEmpty()) {
csValue = "Yes";
}
if (csValue == "Off") {
csValue = "Yes";
}
CFX_ByteString csAS = m_pWidgetDict->GetString("AS", "Off");
if (csAS != "Off") {
m_pWidgetDict->SetAtName("AS", csValue);
}
CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP");
if (pAP == NULL) {
return;
}
FX_POSITION pos1 = pAP->GetStartPos();
while (pos1) {
CFX_ByteString csKey1;
CPDF_Object* pObj1 = pAP->GetNextElement(pos1, csKey1);
if (pObj1 == NULL) {
continue;
}
CPDF_Object* pObjDirect1 = pObj1->GetDirect();
if (pObjDirect1->GetType() != PDFOBJ_DICTIONARY) {
continue;
}
CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)pObjDirect1;
FX_POSITION pos2 = pSubDict->GetStartPos();
while (pos2) {
CFX_ByteString csKey2;
CPDF_Object* pObj2 = pSubDict->GetNextElement(pos2, csKey2);
if (pObj2 == NULL) {
continue;
}
if (csKey2 != "Off") {
pSubDict->ReplaceKey(csKey2, csValue);
break;
}
}
}
}
示例3: SetOnStateName
void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csValue = csOn;
if (csValue.IsEmpty()) {
csValue = "Yes";
}
if (csValue == "Off") {
csValue = "Yes";
}
CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS", "Off");
if (csAS != "Off") {
m_pWidgetDict->SetAtName("AS", csValue);
}
CPDF_Dictionary* pAP = m_pWidgetDict->GetDictBy("AP");
if (!pAP) {
return;
}
for (const auto& it : *pAP) {
CPDF_Object* pObj1 = it.second;
if (!pObj1) {
continue;
}
CPDF_Object* pObjDirect1 = pObj1->GetDirect();
CPDF_Dictionary* pSubDict = pObjDirect1->AsDictionary();
if (!pSubDict)
continue;
auto subdict_it = pSubDict->begin();
while (subdict_it != pSubDict->end()) {
const CFX_ByteString& csKey2 = subdict_it->first;
CPDF_Object* pObj2 = subdict_it->second;
++subdict_it;
if (!pObj2) {
continue;
}
if (csKey2 != "Off") {
pSubDict->ReplaceKey(csKey2, csValue);
break;
}
}
}
}