summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp228
-rw-r--r--core/src/fpdfapi/fpdf_page/pageint.h2
2 files changed, 123 insertions, 107 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 465c74a425..c47fe8bd73 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -340,112 +340,126 @@ void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
}
}
-const CPDF_StreamContentParser::OpCodes CPDF_StreamContentParser::s_OpCodes = {
- {FXBSTR_ID('"', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_NextLineShowText_Space},
- {FXBSTR_ID('\'', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_NextLineShowText},
- {FXBSTR_ID('B', 0, 0, 0), &CPDF_StreamContentParser::Handle_FillStrokePath},
- {FXBSTR_ID('B', '*', 0, 0),
- &CPDF_StreamContentParser::Handle_EOFillStrokePath},
- {FXBSTR_ID('B', 'D', 'C', 0),
- &CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary},
- {FXBSTR_ID('B', 'I', 0, 0), &CPDF_StreamContentParser::Handle_BeginImage},
- {FXBSTR_ID('B', 'M', 'C', 0),
- &CPDF_StreamContentParser::Handle_BeginMarkedContent},
- {FXBSTR_ID('B', 'T', 0, 0), &CPDF_StreamContentParser::Handle_BeginText},
- {FXBSTR_ID('C', 'S', 0, 0),
- &CPDF_StreamContentParser::Handle_SetColorSpace_Stroke},
- {FXBSTR_ID('D', 'P', 0, 0),
- &CPDF_StreamContentParser::Handle_MarkPlace_Dictionary},
- {FXBSTR_ID('D', 'o', 0, 0),
- &CPDF_StreamContentParser::Handle_ExecuteXObject},
- {FXBSTR_ID('E', 'I', 0, 0), &CPDF_StreamContentParser::Handle_EndImage},
- {FXBSTR_ID('E', 'M', 'C', 0),
- &CPDF_StreamContentParser::Handle_EndMarkedContent},
- {FXBSTR_ID('E', 'T', 0, 0), &CPDF_StreamContentParser::Handle_EndText},
- {FXBSTR_ID('F', 0, 0, 0), &CPDF_StreamContentParser::Handle_FillPathOld},
- {FXBSTR_ID('G', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetGray_Stroke},
- {FXBSTR_ID('I', 'D', 0, 0),
- &CPDF_StreamContentParser::Handle_BeginImageData},
- {FXBSTR_ID('J', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineCap},
- {FXBSTR_ID('K', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke},
- {FXBSTR_ID('M', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetMiterLimit},
- {FXBSTR_ID('M', 'P', 0, 0), &CPDF_StreamContentParser::Handle_MarkPlace},
- {FXBSTR_ID('Q', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_RestoreGraphState},
- {FXBSTR_ID('R', 'G', 0, 0),
- &CPDF_StreamContentParser::Handle_SetRGBColor_Stroke},
- {FXBSTR_ID('S', 0, 0, 0), &CPDF_StreamContentParser::Handle_StrokePath},
- {FXBSTR_ID('S', 'C', 0, 0),
- &CPDF_StreamContentParser::Handle_SetColor_Stroke},
- {FXBSTR_ID('S', 'C', 'N', 0),
- &CPDF_StreamContentParser::Handle_SetColorPS_Stroke},
- {FXBSTR_ID('T', '*', 0, 0),
- &CPDF_StreamContentParser::Handle_MoveToNextLine},
- {FXBSTR_ID('T', 'D', 0, 0),
- &CPDF_StreamContentParser::Handle_MoveTextPoint_SetLeading},
- {FXBSTR_ID('T', 'J', 0, 0),
- &CPDF_StreamContentParser::Handle_ShowText_Positioning},
- {FXBSTR_ID('T', 'L', 0, 0),
- &CPDF_StreamContentParser::Handle_SetTextLeading},
- {FXBSTR_ID('T', 'c', 0, 0), &CPDF_StreamContentParser::Handle_SetCharSpace},
- {FXBSTR_ID('T', 'd', 0, 0),
- &CPDF_StreamContentParser::Handle_MoveTextPoint},
- {FXBSTR_ID('T', 'f', 0, 0), &CPDF_StreamContentParser::Handle_SetFont},
- {FXBSTR_ID('T', 'j', 0, 0), &CPDF_StreamContentParser::Handle_ShowText},
- {FXBSTR_ID('T', 'm', 0, 0),
- &CPDF_StreamContentParser::Handle_SetTextMatrix},
- {FXBSTR_ID('T', 'r', 0, 0),
- &CPDF_StreamContentParser::Handle_SetTextRenderMode},
- {FXBSTR_ID('T', 's', 0, 0), &CPDF_StreamContentParser::Handle_SetTextRise},
- {FXBSTR_ID('T', 'w', 0, 0), &CPDF_StreamContentParser::Handle_SetWordSpace},
- {FXBSTR_ID('T', 'z', 0, 0), &CPDF_StreamContentParser::Handle_SetHorzScale},
- {FXBSTR_ID('W', 0, 0, 0), &CPDF_StreamContentParser::Handle_Clip},
- {FXBSTR_ID('W', '*', 0, 0), &CPDF_StreamContentParser::Handle_EOClip},
- {FXBSTR_ID('b', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_CloseFillStrokePath},
- {FXBSTR_ID('b', '*', 0, 0),
- &CPDF_StreamContentParser::Handle_CloseEOFillStrokePath},
- {FXBSTR_ID('c', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_123},
- {FXBSTR_ID('c', 'm', 0, 0), &CPDF_StreamContentParser::Handle_ConcatMatrix},
- {FXBSTR_ID('c', 's', 0, 0),
- &CPDF_StreamContentParser::Handle_SetColorSpace_Fill},
- {FXBSTR_ID('d', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetDash},
- {FXBSTR_ID('d', '0', 0, 0), &CPDF_StreamContentParser::Handle_SetCharWidth},
- {FXBSTR_ID('d', '1', 0, 0),
- &CPDF_StreamContentParser::Handle_SetCachedDevice},
- {FXBSTR_ID('f', 0, 0, 0), &CPDF_StreamContentParser::Handle_FillPath},
- {FXBSTR_ID('f', '*', 0, 0), &CPDF_StreamContentParser::Handle_EOFillPath},
- {FXBSTR_ID('g', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetGray_Fill},
- {FXBSTR_ID('g', 's', 0, 0),
- &CPDF_StreamContentParser::Handle_SetExtendGraphState},
- {FXBSTR_ID('h', 0, 0, 0), &CPDF_StreamContentParser::Handle_ClosePath},
- {FXBSTR_ID('i', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetFlat},
- {FXBSTR_ID('j', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineJoin},
- {FXBSTR_ID('k', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_SetCMYKColor_Fill},
- {FXBSTR_ID('l', 0, 0, 0), &CPDF_StreamContentParser::Handle_LineTo},
- {FXBSTR_ID('m', 0, 0, 0), &CPDF_StreamContentParser::Handle_MoveTo},
- {FXBSTR_ID('n', 0, 0, 0), &CPDF_StreamContentParser::Handle_EndPath},
- {FXBSTR_ID('q', 0, 0, 0), &CPDF_StreamContentParser::Handle_SaveGraphState},
- {FXBSTR_ID('r', 'e', 0, 0), &CPDF_StreamContentParser::Handle_Rectangle},
- {FXBSTR_ID('r', 'g', 0, 0),
- &CPDF_StreamContentParser::Handle_SetRGBColor_Fill},
- {FXBSTR_ID('r', 'i', 0, 0),
- &CPDF_StreamContentParser::Handle_SetRenderIntent},
- {FXBSTR_ID('s', 0, 0, 0),
- &CPDF_StreamContentParser::Handle_CloseStrokePath},
- {FXBSTR_ID('s', 'c', 0, 0),
- &CPDF_StreamContentParser::Handle_SetColor_Fill},
- {FXBSTR_ID('s', 'c', 'n', 0),
- &CPDF_StreamContentParser::Handle_SetColorPS_Fill},
- {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill},
- {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_23},
- {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineWidth},
- {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_13},
-};
+// static
+CPDF_StreamContentParser::OpCodes
+CPDF_StreamContentParser::InitializeOpCodes() {
+ return OpCodes({
+ {FXBSTR_ID('"', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_NextLineShowText_Space},
+ {FXBSTR_ID('\'', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_NextLineShowText},
+ {FXBSTR_ID('B', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_FillStrokePath},
+ {FXBSTR_ID('B', '*', 0, 0),
+ &CPDF_StreamContentParser::Handle_EOFillStrokePath},
+ {FXBSTR_ID('B', 'D', 'C', 0),
+ &CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary},
+ {FXBSTR_ID('B', 'I', 0, 0), &CPDF_StreamContentParser::Handle_BeginImage},
+ {FXBSTR_ID('B', 'M', 'C', 0),
+ &CPDF_StreamContentParser::Handle_BeginMarkedContent},
+ {FXBSTR_ID('B', 'T', 0, 0), &CPDF_StreamContentParser::Handle_BeginText},
+ {FXBSTR_ID('C', 'S', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetColorSpace_Stroke},
+ {FXBSTR_ID('D', 'P', 0, 0),
+ &CPDF_StreamContentParser::Handle_MarkPlace_Dictionary},
+ {FXBSTR_ID('D', 'o', 0, 0),
+ &CPDF_StreamContentParser::Handle_ExecuteXObject},
+ {FXBSTR_ID('E', 'I', 0, 0), &CPDF_StreamContentParser::Handle_EndImage},
+ {FXBSTR_ID('E', 'M', 'C', 0),
+ &CPDF_StreamContentParser::Handle_EndMarkedContent},
+ {FXBSTR_ID('E', 'T', 0, 0), &CPDF_StreamContentParser::Handle_EndText},
+ {FXBSTR_ID('F', 0, 0, 0), &CPDF_StreamContentParser::Handle_FillPathOld},
+ {FXBSTR_ID('G', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_SetGray_Stroke},
+ {FXBSTR_ID('I', 'D', 0, 0),
+ &CPDF_StreamContentParser::Handle_BeginImageData},
+ {FXBSTR_ID('J', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineCap},
+ {FXBSTR_ID('K', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke},
+ {FXBSTR_ID('M', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_SetMiterLimit},
+ {FXBSTR_ID('M', 'P', 0, 0), &CPDF_StreamContentParser::Handle_MarkPlace},
+ {FXBSTR_ID('Q', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_RestoreGraphState},
+ {FXBSTR_ID('R', 'G', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetRGBColor_Stroke},
+ {FXBSTR_ID('S', 0, 0, 0), &CPDF_StreamContentParser::Handle_StrokePath},
+ {FXBSTR_ID('S', 'C', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetColor_Stroke},
+ {FXBSTR_ID('S', 'C', 'N', 0),
+ &CPDF_StreamContentParser::Handle_SetColorPS_Stroke},
+ {FXBSTR_ID('T', '*', 0, 0),
+ &CPDF_StreamContentParser::Handle_MoveToNextLine},
+ {FXBSTR_ID('T', 'D', 0, 0),
+ &CPDF_StreamContentParser::Handle_MoveTextPoint_SetLeading},
+ {FXBSTR_ID('T', 'J', 0, 0),
+ &CPDF_StreamContentParser::Handle_ShowText_Positioning},
+ {FXBSTR_ID('T', 'L', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetTextLeading},
+ {FXBSTR_ID('T', 'c', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetCharSpace},
+ {FXBSTR_ID('T', 'd', 0, 0),
+ &CPDF_StreamContentParser::Handle_MoveTextPoint},
+ {FXBSTR_ID('T', 'f', 0, 0), &CPDF_StreamContentParser::Handle_SetFont},
+ {FXBSTR_ID('T', 'j', 0, 0), &CPDF_StreamContentParser::Handle_ShowText},
+ {FXBSTR_ID('T', 'm', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetTextMatrix},
+ {FXBSTR_ID('T', 'r', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetTextRenderMode},
+ {FXBSTR_ID('T', 's', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetTextRise},
+ {FXBSTR_ID('T', 'w', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetWordSpace},
+ {FXBSTR_ID('T', 'z', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetHorzScale},
+ {FXBSTR_ID('W', 0, 0, 0), &CPDF_StreamContentParser::Handle_Clip},
+ {FXBSTR_ID('W', '*', 0, 0), &CPDF_StreamContentParser::Handle_EOClip},
+ {FXBSTR_ID('b', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_CloseFillStrokePath},
+ {FXBSTR_ID('b', '*', 0, 0),
+ &CPDF_StreamContentParser::Handle_CloseEOFillStrokePath},
+ {FXBSTR_ID('c', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_123},
+ {FXBSTR_ID('c', 'm', 0, 0),
+ &CPDF_StreamContentParser::Handle_ConcatMatrix},
+ {FXBSTR_ID('c', 's', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetColorSpace_Fill},
+ {FXBSTR_ID('d', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetDash},
+ {FXBSTR_ID('d', '0', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetCharWidth},
+ {FXBSTR_ID('d', '1', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetCachedDevice},
+ {FXBSTR_ID('f', 0, 0, 0), &CPDF_StreamContentParser::Handle_FillPath},
+ {FXBSTR_ID('f', '*', 0, 0), &CPDF_StreamContentParser::Handle_EOFillPath},
+ {FXBSTR_ID('g', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetGray_Fill},
+ {FXBSTR_ID('g', 's', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetExtendGraphState},
+ {FXBSTR_ID('h', 0, 0, 0), &CPDF_StreamContentParser::Handle_ClosePath},
+ {FXBSTR_ID('i', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetFlat},
+ {FXBSTR_ID('j', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineJoin},
+ {FXBSTR_ID('k', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_SetCMYKColor_Fill},
+ {FXBSTR_ID('l', 0, 0, 0), &CPDF_StreamContentParser::Handle_LineTo},
+ {FXBSTR_ID('m', 0, 0, 0), &CPDF_StreamContentParser::Handle_MoveTo},
+ {FXBSTR_ID('n', 0, 0, 0), &CPDF_StreamContentParser::Handle_EndPath},
+ {FXBSTR_ID('q', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_SaveGraphState},
+ {FXBSTR_ID('r', 'e', 0, 0), &CPDF_StreamContentParser::Handle_Rectangle},
+ {FXBSTR_ID('r', 'g', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetRGBColor_Fill},
+ {FXBSTR_ID('r', 'i', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetRenderIntent},
+ {FXBSTR_ID('s', 0, 0, 0),
+ &CPDF_StreamContentParser::Handle_CloseStrokePath},
+ {FXBSTR_ID('s', 'c', 0, 0),
+ &CPDF_StreamContentParser::Handle_SetColor_Fill},
+ {FXBSTR_ID('s', 'c', 'n', 0),
+ &CPDF_StreamContentParser::Handle_SetColorPS_Fill},
+ {FXBSTR_ID('s', 'h', 0, 0), &CPDF_StreamContentParser::Handle_ShadeFill},
+ {FXBSTR_ID('v', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_23},
+ {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineWidth},
+ {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_13},
+ });
+}
void CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) {
int i = 0;
@@ -459,6 +473,8 @@ void CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) {
i++;
}
+ static const OpCodes s_OpCodes = InitializeOpCodes();
+
auto it = s_OpCodes.find(opid);
if (it != s_OpCodes.end())
(this->*it->second)();
diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h
index a36b848bca..ec06187b6c 100644
--- a/core/src/fpdfapi/fpdf_page/pageint.h
+++ b/core/src/fpdfapi/fpdf_page/pageint.h
@@ -154,7 +154,7 @@ class CPDF_StreamContentParser {
protected:
using OpCodes =
std::unordered_map<FX_DWORD, void (CPDF_StreamContentParser::*)()>;
- static const OpCodes s_OpCodes;
+ static OpCodes InitializeOpCodes();
void Handle_CloseFillStrokePath();
void Handle_FillStrokePath();