summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_edittext.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-07-03 13:52:33 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-03 13:52:33 +0000
commit1448cc11b9be67d2d1fcd3f2f833cc6f79ad8d42 (patch)
treea18b7e09d4c1c7fea4e92536727fe86c9f75bae6 /fpdfsdk/fpdf_edittext.cpp
parent825f29ce7a61fc5d0ea12c5fd7aaa88984adb965 (diff)
downloadpdfium-1448cc11b9be67d2d1fcd3f2f833cc6f79ad8d42.tar.xz
Add FPDFText_GetTextRenderMode() API
This allows deciding if FPDFPageObj_GetFillColor() or FPDFPageObj_GetStrokeColor() should be used to get the effective color of a text object. Change-Id: Ic6e99a9eb8512b164756da8b5fcd8cd7771271ae Reviewed-on: https://pdfium-review.googlesource.com/36750 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_edittext.cpp')
-rw-r--r--fpdfsdk/fpdf_edittext.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 3115e2a16e..c552d615e4 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -14,6 +14,7 @@
#include "core/fpdfapi/font/cpdf_type1font.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_textobject.h"
+#include "core/fpdfapi/page/cpdf_textstate.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
@@ -27,6 +28,31 @@
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "public/fpdf_edit.h"
+// These checks are here because core/ and public/ cannot depend on each other.
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL) ==
+ FPDF_TEXTRENDERMODE_FILL,
+ "TextRenderingMode::MODE_FILL value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_STROKE) ==
+ FPDF_TEXTRENDERMODE_STROKE,
+ "TextRenderingMode::MODE_STROKE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_STROKE) ==
+ FPDF_TEXTRENDERMODE_FILL_STROKE,
+ "TextRenderingMode::MODE_FILL_STROKE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_INVISIBLE) ==
+ FPDF_TEXTRENDERMODE_INVISIBLE,
+ "TextRenderingMode::MODE_INVISIBLE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_CLIP) ==
+ FPDF_TEXTRENDERMODE_FILL_CLIP,
+ "TextRenderingMode::MODE_FILL_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_STROKE_CLIP) ==
+ FPDF_TEXTRENDERMODE_STROKE_CLIP,
+ "TextRenderingMode::MODE_STROKE_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_STROKE_CLIP) ==
+ FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP,
+ "TextRenderingMode::MODE_FILL_STROKE_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_CLIP) ==
+ FPDF_TEXTRENDERMODE_CLIP,
+ "TextRenderingMode::MODE_CLIP value mismatch");
namespace {
CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
@@ -545,3 +571,14 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
pTextObj->DefaultStates();
return FPDFPageObjectFromCPDFPageObject(pTextObj.release());
}
+
+FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text) {
+ if (!text)
+ return -1;
+
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return -1;
+
+ return static_cast<int>(pTextObj->m_TextState.GetTextMode());
+}