summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/BUILD.gn1
-rw-r--r--fpdfsdk/fpdf_edit_unittest.cpp41
-rw-r--r--fpdfsdk/fpdf_editimg_unittest.cpp8
-rw-r--r--fpdfsdk/fpdf_editpage.cpp6
-rw-r--r--fpdfsdk/fpdf_view_c_api_test.c1
-rw-r--r--public/fpdf_edit.h10
6 files changed, 63 insertions, 4 deletions
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index ea44f0d410..3b1a04b8a2 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -95,6 +95,7 @@ pdfium_unittest_source_set("unittests") {
sources = [
"fpdf_catalog_unittest.cpp",
"fpdf_doc_unittest.cpp",
+ "fpdf_edit_unittest.cpp",
"fpdf_editimg_unittest.cpp",
]
deps = [
diff --git a/fpdfsdk/fpdf_edit_unittest.cpp b/fpdfsdk/fpdf_edit_unittest.cpp
new file mode 100644
index 0000000000..7171f306dc
--- /dev/null
+++ b/fpdfsdk/fpdf_edit_unittest.cpp
@@ -0,0 +1,41 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "public/fpdf_edit.h"
+
+#include "core/fpdfapi/cpdf_modulemgr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class PDFEditTest : public testing::Test {
+ void SetUp() override { CPDF_ModuleMgr::Get()->Init(); }
+
+ void TearDown() override { CPDF_ModuleMgr::Destroy(); }
+};
+
+TEST_F(PDFEditTest, LineJoin) {
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, -1));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, FPDF_LINEJOIN_MITER));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, FPDF_LINEJOIN_ROUND));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, FPDF_LINEJOIN_BEVEL));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, 3));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, 1000));
+
+ FPDF_PAGEOBJECT path = FPDFPageObj_CreateNewPath(0, 0);
+ EXPECT_EQ(FPDF_LINEJOIN_MITER, FPDFPageObj_GetLineJoin(path));
+
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(path, -1));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(path, 3));
+ EXPECT_FALSE(FPDFPageObj_SetLineJoin(path, 1000));
+
+ EXPECT_TRUE(FPDFPageObj_SetLineJoin(path, FPDF_LINEJOIN_BEVEL));
+ EXPECT_EQ(FPDF_LINEJOIN_BEVEL, FPDFPageObj_GetLineJoin(path));
+
+ EXPECT_TRUE(FPDFPageObj_SetLineJoin(path, FPDF_LINEJOIN_ROUND));
+ EXPECT_EQ(FPDF_LINEJOIN_ROUND, FPDFPageObj_GetLineJoin(path));
+
+ EXPECT_TRUE(FPDFPageObj_SetLineJoin(path, FPDF_LINEJOIN_MITER));
+ EXPECT_EQ(FPDF_LINEJOIN_MITER, FPDFPageObj_GetLineJoin(path));
+
+ FPDFPageObj_Destroy(path);
+}
diff --git a/fpdfsdk/fpdf_editimg_unittest.cpp b/fpdfsdk/fpdf_editimg_unittest.cpp
index fcc081ab76..48bd7f146b 100644
--- a/fpdfsdk/fpdf_editimg_unittest.cpp
+++ b/fpdfsdk/fpdf_editimg_unittest.cpp
@@ -7,13 +7,13 @@
#include "core/fpdfapi/cpdf_modulemgr.h"
#include "testing/gtest/include/gtest/gtest.h"
-class PDFEditTest : public testing::Test {
+class PDFEditImgTest : public testing::Test {
void SetUp() override { CPDF_ModuleMgr::Get()->Init(); }
void TearDown() override { CPDF_ModuleMgr::Destroy(); }
};
-TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
+TEST_F(PDFEditImgTest, InsertObjectWithInvalidPage) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
EXPECT_EQ(0, FPDFPage_CountObjects(page));
@@ -32,7 +32,7 @@ TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
FPDF_CloseDocument(doc);
}
-TEST_F(PDFEditTest, NewImageObj) {
+TEST_F(PDFEditImgTest, NewImageObj) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
EXPECT_EQ(0, FPDFPage_CountObjects(page));
@@ -46,7 +46,7 @@ TEST_F(PDFEditTest, NewImageObj) {
FPDF_CloseDocument(doc);
}
-TEST_F(PDFEditTest, NewImageObjGenerateContent) {
+TEST_F(PDFEditImgTest, NewImageObjGenerateContent) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
EXPECT_EQ(0, FPDFPage_CountObjects(page));
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index d0ff962252..27767465b3 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -793,6 +793,12 @@ FPDFPageObj_GetStrokeWidth(FPDF_PAGEOBJECT page_object, float* width) {
return true;
}
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFPageObj_GetLineJoin(FPDF_PAGEOBJECT page_object) {
+ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
+ return pPageObj ? pPageObj->m_GraphState.GetLineJoin() : -1;
+}
+
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join) {
auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index 9cf037685e..eb66e14c37 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -157,6 +157,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPageObj_Destroy);
CHK(FPDFPageObj_GetBounds);
CHK(FPDFPageObj_GetFillColor);
+ CHK(FPDFPageObj_GetLineJoin);
CHK(FPDFPageObj_GetMark);
CHK(FPDFPageObj_GetStrokeColor);
CHK(FPDFPageObj_GetStrokeWidth);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 180d50247e..4babd7ea3a 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -835,6 +835,16 @@ FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width);
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_GetStrokeWidth(FPDF_PAGEOBJECT page_object, float* width);
+// Get the line join of |page_object|.
+//
+// page_object - handle to a page object.
+//
+// Returns the line join, or -1 on failure.
+// Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND,
+// FPDF_LINEJOIN_BEVEL
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFPageObj_GetLineJoin(FPDF_PAGEOBJECT page_object);
+
// DEPRECATED as of May 2018. This API will be removed in the future. Please
// use FPDFPageObj_SetLineJoin instead.
//