本文整理汇总了C++中CPDF_Object::IsString方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Object::IsString方法的具体用法?C++ CPDF_Object::IsString怎么用?C++ CPDF_Object::IsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Object
的用法示例。
在下文中一共展示了CPDF_Object::IsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
std::vector<CPDF_Object*> fields;
if (!m_pAction)
return fields;
CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return fields;
CFX_ByteString csType = pDict->GetStringFor("S");
CPDF_Object* pFields;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
else
pFields = pDict->GetArrayFor("Fields");
if (!pFields)
return fields;
if (pFields->IsDictionary() || pFields->IsString()) {
fields.push_back(pFields);
} else if (CPDF_Array* pArray = pFields->AsArray()) {
for (size_t i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (pObj)
fields.push_back(pObj);
}
}
return fields;
}
示例2: GetFieldsCount
FX_DWORD CPDF_ActionFields::GetFieldsCount() const {
if (!m_pAction) {
return 0;
}
CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict) {
return 0;
}
CFX_ByteString csType = pDict->GetString("S");
CPDF_Object* pFields = NULL;
if (csType == "Hide") {
pFields = pDict->GetElementValue("T");
} else {
pFields = pDict->GetArray("Fields");
}
if (!pFields)
return 0;
if (pFields->IsDictionary())
return 1;
if (pFields->IsString())
return 1;
if (CPDF_Array* pArray = pFields->AsArray())
return pArray->GetCount();
return 0;
}
示例3: if
std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
std::vector<CPDF_Object*> fields;
if (!m_pAction)
return fields;
CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return fields;
CFX_ByteString csType = pDict->GetString("S");
CPDF_Object* pFields;
if (csType == "Hide")
pFields = pDict->GetElementValue("T");
else
pFields = pDict->GetArray("Fields");
if (!pFields)
return fields;
if (pFields->IsDictionary() || pFields->IsString()) {
fields.push_back(pFields);
} else if (CPDF_Array* pArray = pFields->AsArray()) {
FX_DWORD iCount = pArray->GetCount();
for (FX_DWORD i = 0; i < iCount; ++i) {
CPDF_Object* pObj = pArray->GetElementValue(i);
if (pObj) {
fields.push_back(pObj);
}
}
}
return fields;
}
示例4: GetField
CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
if (!m_pAction) {
return NULL;
}
CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict) {
return NULL;
}
CFX_ByteString csType = pDict->GetString("S");
CPDF_Object* pFields = NULL;
if (csType == "Hide") {
pFields = pDict->GetElementValue("T");
} else {
pFields = pDict->GetArray("Fields");
}
if (!pFields) {
return NULL;
}
CPDF_Object* pFindObj = NULL;
if (pFields->IsDictionary() || pFields->IsString()) {
if (iIndex == 0)
pFindObj = pFields;
} else if (CPDF_Array* pArray = pFields->AsArray()) {
pFindObj = pArray->GetElementValue(iIndex);
}
return pFindObj;
}
示例5: GetField
CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
if (!m_pAction)
return nullptr;
CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return nullptr;
CFX_ByteString csType = pDict->GetStringFor("S");
CPDF_Object* pFields = nullptr;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
else
pFields = pDict->GetArrayFor("Fields");
if (!pFields)
return nullptr;
CPDF_Object* pFindObj = nullptr;
if (pFields->IsDictionary() || pFields->IsString()) {
if (iIndex == 0)
pFindObj = pFields;
} else if (CPDF_Array* pArray = pFields->AsArray()) {
pFindObj = pArray->GetDirectObjectAt(iIndex);
}
return pFindObj;
}
示例6: GetFieldsCount
size_t CPDF_ActionFields::GetFieldsCount() const {
if (!m_pAction)
return 0;
CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return 0;
CFX_ByteString csType = pDict->GetStringFor("S");
CPDF_Object* pFields = nullptr;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
else
pFields = pDict->GetArrayFor("Fields");
if (!pFields)
return 0;
if (pFields->IsDictionary())
return 1;
if (pFields->IsString())
return 1;
if (CPDF_Array* pArray = pFields->AsArray())
return pArray->GetCount();
return 0;
}
示例7: SetItemSelection
bool CPDF_FormField::SetItemSelection(int index, bool bSelected, 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->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false);
} else {
CPDF_Array* pArray = m_pDict->SetNewFor<CPDF_Array>("V");
for (int i = 0; i < CountOptions(); i++) {
if (i == index || IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false);
}
}
}
} else {
m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false);
CPDF_Array* pI = m_pDict->SetNewFor<CPDF_Array>("I");
pI->AddNew<CPDF_Number>(index);
}
} 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> pArray(new CPDF_Array);
for (int i = 0; i < CountOptions(); i++) {
if (i != index && IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false);
}
}
if (pArray->GetCount() > 0)
m_pDict->SetFor("V", std::move(pArray));
}
} else {
m_pDict->RemoveFor("V");
m_pDict->RemoveFor("I");
}
}
}
if (bNotify)
NotifyListOrComboBoxAfterChange();
return true;
}
示例8: CountSelectedItems
int CPDF_FormField::CountSelectedItems() const {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict, "I");
if (!pValue)
return 0;
}
if (pValue->IsString() || pValue->IsNumber())
return pValue->GetString().IsEmpty() ? 0 : 1;
if (CPDF_Array* pArray = pValue->AsArray())
return pArray->GetCount();
return 0;
}
示例9: GetDest
CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) {
CPDF_Object* pDest = m_pDict->GetElementValue("Dest");
if (!pDest)
return CPDF_Dest();
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests"));
CFX_ByteStringC name = pDest->GetString();
return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
return CPDF_Dest();
}
示例10: Handle_ShowText_Positioning
void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
if (!pArray) {
return;
}
int n = pArray->GetCount();
int nsegs = 0;
for (int i = 0; i < n; i++) {
if (pArray->GetElementValue(i)->IsString())
nsegs++;
}
if (nsegs == 0) {
for (int i = 0; i < n; i++) {
m_pCurStates->m_TextX -=
FXSYS_Mul(pArray->GetNumber(i),
m_pCurStates->m_TextState.GetFontSize()) /
1000;
}
return;
}
CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
int iSegment = 0;
FX_FLOAT fInitKerning = 0;
for (int i = 0; i < n; i++) {
CPDF_Object* pObj = pArray->GetElementValue(i);
if (pObj->IsString()) {
CFX_ByteString str = pObj->GetString();
if (str.IsEmpty()) {
continue;
}
pStrs[iSegment] = str;
pKerning[iSegment++] = 0;
} else {
FX_FLOAT num = pObj ? pObj->GetNumber() : 0;
if (iSegment == 0) {
fInitKerning += num;
} else {
pKerning[iSegment - 1] += num;
}
}
}
AddTextObject(pStrs, fInitKerning, pKerning, iSegment);
delete[] pStrs;
FX_Free(pKerning);
}
示例11: IsItemSelected
FX_BOOL CPDF_FormField::IsItemSelected(int index) const {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions()) {
return FALSE;
}
if (IsOptionSelected(index)) {
return TRUE;
}
CFX_WideString opt_value = GetOptionValue(index);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict, "I");
if (!pValue) {
return FALSE;
}
}
if (pValue->IsString())
return pValue->GetUnicodeText() == opt_value;
if (pValue->IsNumber()) {
if (pValue->GetString().IsEmpty())
return FALSE;
return (pValue->GetInteger() == index);
}
CPDF_Array* pArray = pValue->AsArray();
if (!pArray)
return FALSE;
int iPos = -1;
for (int j = 0; j < CountSelectedOptions(); j++) {
if (GetSelectedOptionIndex(j) == index) {
iPos = j;
break;
}
}
for (int i = 0; i < static_cast<int>(pArray->GetCount()); i++)
if (pArray->GetDirectObjectAt(i)->GetUnicodeText() == opt_value &&
i == iPos) {
return TRUE;
}
return FALSE;
}
示例12: GetDest
CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
if (!m_pDict)
return CPDF_Dest();
CFX_ByteString type = m_pDict->GetStringFor("S");
if (type != "GoTo" && type != "GoToR")
return CPDF_Dest();
CPDF_Object* pDest = m_pDict->GetDirectObjectFor("D");
if (!pDest)
return CPDF_Dest();
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDoc, "Dests");
return CPDF_Dest(name_tree.LookupNamedDest(pDoc, pDest->GetString()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
return CPDF_Dest();
}
示例13: GetSelectedIndex
int CPDF_FormField::GetSelectedIndex(int index) {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict, "I");
if (!pValue)
return -1;
}
if (pValue->IsNumber())
return pValue->GetInteger();
CFX_WideString sel_value;
if (pValue->IsString()) {
if (index != 0)
return -1;
sel_value = pValue->GetUnicodeText();
} else {
CPDF_Array* pArray = pValue->AsArray();
if (!pArray || index < 0)
return -1;
CPDF_Object* elementValue = pArray->GetElementValue(index);
sel_value =
elementValue ? elementValue->GetUnicodeText() : CFX_WideString();
}
if (index < CountSelectedOptions()) {
int iOptIndex = GetSelectedOptionIndex(index);
CFX_WideString csOpt = GetOptionValue(iOptIndex);
if (csOpt == sel_value) {
return iOptIndex;
}
}
int nOpts = CountOptions();
for (int i = 0; i < nOpts; i++) {
if (sel_value == GetOptionValue(i)) {
return i;
}
}
return -1;
}
示例14: SetItemSelection
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;
}
示例15: SetItemSelection
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;
}