summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_edit_embeddertest.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-08-14 19:15:43 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-14 19:15:43 +0000
commit46b437333e53295869afde696ed31043c1f6c717 (patch)
tree25c8b199bd5b601d18c1c87f8e20bae9c8510c50 /fpdfsdk/fpdf_edit_embeddertest.cpp
parent9e4a66449a227ca2a9e62d2f83fdc35f11bb5e2d (diff)
downloadpdfium-46b437333e53295869afde696ed31043c1f6c717.tar.xz
Add FPDFFormObj_GetMatrix() API
This is similar to FPDFText_GetMatrix() (wrapping CPDF_TextObject::GetTextMatrix()) and FPDFPath_GetMatrix() (wrapping CPDF_PathObject::m_Matrix), but wraps the matrix of form objects: CPDF_FormObject::form_matrix(). Change-Id: Ic4ce7ad8050012f54de356bb936263d3e4f097ca Reviewed-on: https://pdfium-review.googlesource.com/39930 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_edit_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index e692a94e04..b957ca3dcc 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -8,6 +8,7 @@
#include <vector>
#include "core/fpdfapi/font/cpdf_font.h"
+#include "core/fpdfapi/page/cpdf_formobject.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/page/cpdf_pageobject.h"
#include "core/fpdfapi/parser/cpdf_array.h"
@@ -1823,6 +1824,39 @@ TEST_F(FPDFEditEmbeddertest, TestFormGetObjects) {
ASSERT_EQ(nullptr, FPDFFormObj_GetObject(form, -1));
ASSERT_EQ(nullptr, FPDFFormObj_GetObject(form, 2));
+ // Reset the form object matrix to identity.
+ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(form);
+ CPDF_FormObject* pFormObj = pPageObj->AsForm();
+ pFormObj->Transform(pFormObj->form_matrix().GetInverse());
+
+ // FPDFFormObj_GetMatrix() positive testing.
+ static constexpr float kFloats[6] = {1.0, 1.5, 2.0, 2.5, 100.0, 200.0};
+ CFX_Matrix matrix(kFloats);
+ pFormObj->Transform(matrix);
+
+ double matrix_a = 0;
+ double matrix_b = 0;
+ double matrix_c = 0;
+ double matrix_d = 0;
+ double matrix_e = 0;
+ double matrix_f = 0;
+ EXPECT_TRUE(FPDFFormObj_GetMatrix(form, &matrix_a, &matrix_b, &matrix_c,
+ &matrix_d, &matrix_e, &matrix_f));
+ EXPECT_DOUBLE_EQ(kFloats[0], matrix_a);
+ EXPECT_DOUBLE_EQ(kFloats[1], matrix_b);
+ EXPECT_DOUBLE_EQ(kFloats[2], matrix_c);
+ EXPECT_DOUBLE_EQ(kFloats[3], matrix_d);
+ EXPECT_DOUBLE_EQ(kFloats[4], matrix_e);
+ EXPECT_DOUBLE_EQ(kFloats[5], matrix_f);
+
+ // FPDFFormObj_GetMatrix() negative testing.
+ EXPECT_FALSE(FPDFFormObj_GetMatrix(nullptr, &matrix_a, &matrix_b, &matrix_c,
+ &matrix_d, &matrix_e, &matrix_f));
+ EXPECT_FALSE(FPDFFormObj_GetMatrix(form, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr));
+ EXPECT_FALSE(FPDFFormObj_GetMatrix(nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr));
+
UnloadPage(page);
}