1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
From 914467a56b9c4cd6a27cfa9b7ed61ebfb5a122d3 Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Tue, 5 Jun 2018 11:29:49 +0200
Subject: [PATCH 04/14] svx: support PDF text color
---
pdfium/fpdfsdk/cpdfsdk_helpers.h | 5 +++++
pdfium/fpdfsdk/fpdf_editpage.cpp | 30 +++++++++++++++++++++++++-----
pdfium/public/fpdf_edit.h | 16 ++++++++++++++++
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/pdfium/fpdfsdk/cpdfsdk_helpers.h b/pdfium/fpdfsdk/cpdfsdk_helpers.h
index d93ecfc..13362cf 100644
--- a/pdfium/fpdfsdk/cpdfsdk_helpers.h
+++ b/pdfium/fpdfsdk/cpdfsdk_helpers.h
@@ -204,6 +204,11 @@ inline CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(
return reinterpret_cast<CPDF_TextPageFind*>(handle);
}
+inline CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(
+ FPDF_PAGEOBJECT page_object) {
+ return reinterpret_cast<CPDF_TextObject*>(page_object);
+}
+
ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string);
#ifdef PDF_ENABLE_XFA
diff --git a/pdfium/fpdfsdk/fpdf_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp
index 3244943..f8e2418 100644
--- a/pdfium/fpdfsdk/fpdf_editpage.cpp
+++ b/pdfium/fpdfsdk/fpdf_editpage.cpp
@@ -443,7 +443,7 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object)
if (!text_object)
return 0;
- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
+ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
return pTxtObj->CountChars();
}
@@ -453,7 +453,7 @@ FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object)
if (!text_object)
return 0;
- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
+ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
return pTxtObj->GetFontSize();
}
@@ -645,3 +645,23 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
pPageObj->SetDirty(true);
return true;
}
+
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFTextObj_GetStrokeColor(FPDF_PAGEOBJECT text_object,
+ unsigned int* R,
+ unsigned int* G,
+ unsigned int* B,
+ unsigned int* A)
+{
+ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ if (!pTxtObj || !R || !G || !B || !A)
+ return false;
+
+ const uint32_t strokeRGB = pTxtObj->m_ColorState.GetStrokeRGB();
+ *R = FXSYS_GetRValue(strokeRGB);
+ *G = FXSYS_GetGValue(strokeRGB);
+ *B = FXSYS_GetBValue(strokeRGB);
+ *A = static_cast<unsigned int>(
+ (pTxtObj->m_GeneralState.GetStrokeAlpha() * 255.f) + 0.5f);
+ return true;
+}
diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
index 602849f..fa9902e 100644
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1016,6 +1016,22 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
FPDF_EXPORT int FPDF_CALLCONV
FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
+// Get the stroke RGBA of a text. Range of values: 0 - 255.
+//
+// path - the handle to the path object.
+// R - the red component of the path stroke color.
+// G - the green component of the path stroke color.
+// B - the blue component of the path stroke color.
+// A - the stroke alpha of the path.
+//
+// Returns TRUE on success.
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFTextObj_GetStrokeColor(FPDF_PAGEOBJECT text_object,
+ unsigned int* R,
+ unsigned int* G,
+ unsigned int* B,
+ unsigned int* A);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
diff --git a/pdfium/fpdfsdk/fpdf_edittext.cpp b/pdfium/fpdfsdk/fpdf_edittext.cpp
index c38873faa..aa3287ef4 100644
--- a/pdfium/fpdfsdk/fpdf_edittext.cpp
+++ b/pdfium/fpdfsdk/fpdf_edittext.cpp
@@ -398,11 +398,6 @@ CPDF_Font* LoadCompositeFont(CPDF_Document* pDoc,
return pDoc->LoadFont(fontDict);
}
-CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
- auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
- return obj ? obj->AsText() : nullptr;
-}
-
} // namespace
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
--
2.16.3
|