7#include "core/fpdfdoc/cpdf_pagelabel.h"
12#include "core/fpdfapi/parser/cpdf_dictionary.h"
13#include "core/fpdfapi/parser/cpdf_document.h"
14#include "core/fpdfapi/parser/fpdf_parser_decode.h"
15#include "core/fpdfdoc/cpdf_numbertree.h"
16#include "core/fxcrt/stl_util.h"
21 constexpr auto kArabic =
fxcrt::ToArray<
const int>(
22 {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1});
24 {L"m", L"cm", L"d", L"cd", L"c", L"xc", L"l", L"xl", L"x", L"ix", L"v",
26 constexpr int kMaxNum = 1000000;
33 while (num >= kArabic[i]) {
47 constexpr int kMaxCount = 1000;
48 constexpr int kLetterCount = 26;
51 const int count = (num / kLetterCount + 1) % kMaxCount;
52 const wchar_t ch = L'a' + num % kLetterCount;
56 auto result_span = result.GetBuffer(count);
57 fxcrt::Fill(result_span, ch);
58 result.ReleaseBuffer(count);
64 if (style.IsEmpty()) {
76 return MakeRoman(num);
84 return MakeLetters(num);
100 if (page_index < 0 || page_index >= doc_->GetPageCount()) {
110 root_dict->GetDictFor(
"PageLabels");
118 number_tree.GetLowerBound(page_index);
119 if (lower_bound.has_value()) {
120 label_value = lower_bound.value().value;
124 label_value ? label_value->GetDirect()->AsDictionary() :
nullptr;
137 label
+= GetLabelNumPortion(label_number, style);
fxcrt::ByteString ByteString
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
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
CPDF_PageLabel(CPDF_Document *doc)
std::optional< WideString > GetLabel(int page_index) const
bool operator==(const char *ptr) const
WideString & operator+=(const WideString &str)
WideString & operator=(WideString &&that) noexcept
static WideString FormatInteger(int i)
fxcrt::WideStringView WideStringView
fxcrt::WideString WideString