7#include "core/fpdfdoc/cpdf_pagelabel.h"
11#include "core/fpdfapi/parser/cpdf_dictionary.h"
12#include "core/fpdfapi/parser/cpdf_document.h"
13#include "core/fpdfapi/parser/fpdf_parser_decode.h"
14#include "core/fpdfdoc/cpdf_numbertree.h"
18WideString MakeRoman(
int num) {
19 const int kArabic[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
20 const WideStringView kRoman[] = {L"m", L"cm", L"d", L"cd", L"c",
21 L"xc", L"l", L"xl", L"x", L"ix",
23 const int kMaxNum = 1000000;
27 WideString wsRomanNumber;
29 while (num >= kArabic[i]) {
30 num = num - kArabic[i];
31 wsRomanNumber += kRoman[i];
38WideString MakeLetters(
int num) {
43 const int nMaxCount = 1000;
44 const int nLetterCount = 26;
47 int count = num / nLetterCount + 1;
49 wchar_t ch = L'a' + num % nLetterCount;
50 for (
int i = 0; i < count; i++)
55WideString GetLabelNumPortion(
int num,
const ByteString& bsStyle) {
61 WideString wsNumPortion = MakeRoman(num);
66 return MakeRoman(num);
68 WideString wsNumPortion = MakeLetters(num);
73 return MakeLetters(num);
88 if (nPage < 0 || nPage >= m_pDocument->GetPageCount())
91 const CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
95 RetainPtr<
const CPDF_Dictionary> pLabels = pPDFRoot->GetDictFor(
"PageLabels");
110 pValue = pValue->GetDirect();
111 if (
const CPDF_Dictionary* pLabel = pValue->AsDictionary()) {
118 WideString wsNumPortion = GetLabelNumPortion(nLabelNum, bsNumberingStyle);
119 label
+= wsNumPortion;
bool KeyExist(const ByteString &key) const
ByteString GetByteStringFor(const ByteString &key, const ByteString &default_str) const
WideString GetUnicodeTextFor(const ByteString &key) const
int GetIntegerFor(const ByteString &key, int default_int) const
RetainPtr< const CPDF_Object > LookupValue(int num) const
absl::optional< WideString > GetLabel(int nPage) const
CPDF_PageLabel(CPDF_Document *pDocument)
bool operator==(const char *ptr) const
WideString & operator+=(const WideString &str)
WideString & operator+=(wchar_t ch)
static WideString FormatInteger(int i)