CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { CFX_WideString wsLabel; if (m_pDocument == NULL) { return wsLabel; } CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); if (pPDFRoot == NULL) { return wsLabel; } CPDF_Dictionary* pLabels = pPDFRoot->GetDict(FX_BSTRC("PageLabels")); CPDF_NumberTree numberTree(pLabels); CPDF_Object* pValue = NULL; int n = nPage; while (n >= 0) { pValue = numberTree.LookupValue(n); if (pValue != NULL) { break; } n--; } if (pValue != NULL) { pValue = pValue->GetDirect(); if (pValue->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pLabel = (CPDF_Dictionary*)pValue; if (pLabel->KeyExist(FX_BSTRC("P"))) { wsLabel += pLabel->GetUnicodeText(FX_BSTRC("P")); } CFX_ByteString bsNumberingStyle = pLabel->GetString(FX_BSTRC("S"), NULL); int nLabelNum = nPage - n + pLabel->GetInteger(FX_BSTRC("St"), 1); CFX_WideString wsNumPortion = _GetLabelNumPortion(nLabelNum, bsNumberingStyle); wsLabel += wsNumPortion; return wsLabel; } } wsLabel.Format(L"%d", nPage + 1); return wsLabel; }
CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { CFX_WideString wsLabel; if (!m_pDocument) { return wsLabel; } CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); if (!pPDFRoot) { return wsLabel; } CPDF_Dictionary* pLabels = pPDFRoot->GetDictBy("PageLabels"); CPDF_NumberTree numberTree(pLabels); CPDF_Object* pValue = NULL; int n = nPage; while (n >= 0) { pValue = numberTree.LookupValue(n); if (pValue) { break; } n--; } if (pValue) { pValue = pValue->GetDirect(); if (CPDF_Dictionary* pLabel = pValue->AsDictionary()) { if (pLabel->KeyExist("P")) { wsLabel += pLabel->GetUnicodeTextBy("P"); } CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", NULL); int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1); CFX_WideString wsNumPortion = _GetLabelNumPortion(nLabelNum, bsNumberingStyle); wsLabel += wsNumPortion; return wsLabel; } } wsLabel.Format(L"%d", nPage + 1); return wsLabel; }