Teach FPDFPageObj_SetMatrix() to set the matrix for text objects. [pdfium : main]

48 views
Skip to first unread message

Tom Sepez (Gerrit)

unread,
Jun 29, 2021, 7:38:43 PM6/29/21
to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com

Attention is currently required from: Lei Zhang.

View Change

1 comment:

  • File core/fpdfapi/page/cpdf_textobject.cpp:

To view, visit change 82614. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: Ic1cd9a5d95a3760da39fd00c1d9d388c1e2aa23d
Gerrit-Change-Number: 82614
Gerrit-PatchSet: 2
Gerrit-Owner: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Comment-Date: Tue, 29 Jun 2021 23:38:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Lei Zhang (Gerrit)

unread,
Jun 29, 2021, 8:21:06 PM6/29/21
to Lei Zhang, Tom Sepez, Pdfium LUCI CQ, pdfium-...@googlegroups.com

Attention is currently required from: Tom Sepez.

View Change

1 comment:

  • File core/fpdfapi/page/cpdf_textobject.cpp:

    • Both callers call SetDirty(true). I can add a comment to document the expectation.

To view, visit change 82614. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: Ic1cd9a5d95a3760da39fd00c1d9d388c1e2aa23d
Gerrit-Change-Number: 82614
Gerrit-PatchSet: 2
Gerrit-Owner: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Comment-Date: Wed, 30 Jun 2021 00:21:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
Gerrit-MessageType: comment

Tom Sepez (Gerrit)

unread,
Jun 29, 2021, 9:13:22 PM6/29/21
to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com

Attention is currently required from: Lei Zhang.

Patch set 2:Code-Review +1

View Change

1 comment:

  • File core/fpdfapi/page/cpdf_textobject.cpp:

    • Both callers call SetDirty(true). I can add a comment to document the expectation.

      Ack

To view, visit change 82614. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: Ic1cd9a5d95a3760da39fd00c1d9d388c1e2aa23d
Gerrit-Change-Number: 82614
Gerrit-PatchSet: 2
Gerrit-Owner: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Comment-Date: Wed, 30 Jun 2021 01:13:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>

Lei Zhang (Gerrit)

unread,
Jun 29, 2021, 11:12:42 PM6/29/21
to Lei Zhang, Tom Sepez, Pdfium LUCI CQ, pdfium-...@googlegroups.com

Attention is currently required from: Lei Zhang.

Patch set 3:Commit-Queue +2

View Change

    To view, visit change 82614. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic1cd9a5d95a3760da39fd00c1d9d388c1e2aa23d
    Gerrit-Change-Number: 82614
    Gerrit-PatchSet: 3
    Gerrit-Owner: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Lei Zhang <the...@chromium.org>
    Gerrit-Comment-Date: Wed, 30 Jun 2021 03:12:39 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Pdfium LUCI CQ (Gerrit)

    unread,
    Jun 30, 2021, 12:11:24 AM6/30/21
    to Lei Zhang, Tom Sepez, pdfium-...@googlegroups.com

    Pdfium LUCI CQ submitted this change.

    View Change

    Approvals: Tom Sepez: Looks good to me Lei Zhang: Commit
    Teach FPDFPageObj_SetMatrix() to set the matrix for text objects.

    Convert an embedder test to use the new API capability, instead of
    accessing the internal CPDF_TextObject directly.

    Change-Id: Ic1cd9a5d95a3760da39fd00c1d9d388c1e2aa23d
    Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82614
    Commit-Queue: Lei Zhang <the...@chromium.org>
    Reviewed-by: Tom Sepez <tse...@chromium.org>
    ---
    M core/fpdfapi/page/cpdf_textobject.cpp
    M core/fpdfapi/page/cpdf_textobject.h
    M fpdfsdk/fpdf_edit_embeddertest.cpp
    M fpdfsdk/fpdf_editpage.cpp
    4 files changed, 19 insertions(+), 13 deletions(-)

    diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
    index eca37ab..edc2f5f 100644
    --- a/core/fpdfapi/page/cpdf_textobject.cpp
    +++ b/core/fpdfapi/page/cpdf_textobject.cpp
    @@ -155,15 +155,7 @@
    }

    void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
    - CFX_Matrix text_matrix = GetTextMatrix() * matrix;
    -
    - float* pTextMatrix = m_TextState.GetMutableMatrix();
    - pTextMatrix[0] = text_matrix.a;
    - pTextMatrix[1] = text_matrix.c;
    - pTextMatrix[2] = text_matrix.b;
    - pTextMatrix[3] = text_matrix.d;
    - m_Pos = CFX_PointF(text_matrix.e, text_matrix.f);
    - CalcPositionData(0);
    + SetTextMatrix(GetTextMatrix() * matrix);
    SetDirty(true);
    }

    @@ -185,6 +177,16 @@
    pTextMatrix[3], m_Pos.x, m_Pos.y);
    }

    +void CPDF_TextObject::SetTextMatrix(const CFX_Matrix& matrix) {
    + float* pTextMatrix = m_TextState.GetMutableMatrix();
    + pTextMatrix[0] = matrix.a;
    + pTextMatrix[1] = matrix.c;
    + pTextMatrix[2] = matrix.b;
    + pTextMatrix[3] = matrix.d;
    + m_Pos = CFX_PointF(matrix.e, matrix.f);
    + CalcPositionData(0);
    +}
    +
    void CPDF_TextObject::SetSegments(const ByteString* pStrs,
    const std::vector<float>& kernings,
    size_t nSegs) {
    diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
    index c650352..2fe269f 100644
    --- a/core/fpdfapi/page/cpdf_textobject.h
    +++ b/core/fpdfapi/page/cpdf_textobject.h
    @@ -30,7 +30,7 @@
    CPDF_TextObject();
    ~CPDF_TextObject() override;

    - // CPDF_PageObject
    + // CPDF_PageObject:
    Type GetType() const override;
    void Transform(const CFX_Matrix& matrix) override;
    bool IsText() const override;
    @@ -66,6 +66,9 @@
    const std::vector<uint32_t>& GetCharCodes() const { return m_CharCodes; }
    const std::vector<float>& GetCharPositions() const { return m_CharPos; }

    + // Caller is expected to call SetDirty(true) when done changing the object.
    + void SetTextMatrix(const CFX_Matrix& matrix);
    +
    void SetSegments(const ByteString* pStrs,
    const std::vector<float>& kernings,
    size_t nSegs);
    diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
    index 11fca24..f16f5d5 100644
    --- a/fpdfsdk/fpdf_edit_embeddertest.cpp
    +++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
    @@ -9,7 +9,6 @@

    #include "build/build_config.h"
    #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"
    @@ -2211,7 +2210,8 @@
    EXPECT_TRUE(text_object1);
    ScopedFPDFWideString text1 = GetFPDFWideString(kBottomText);
    EXPECT_TRUE(FPDFText_SetText(text_object1, text1.get()));
    - FPDFPageObj_Transform(text_object1, 1, 0, 0, 1, 20, 20);
    + static constexpr FS_MATRIX kMatrix1{1, 0, 0, 1, 20, 20};
    + EXPECT_TRUE(FPDFPageObj_SetMatrix(text_object1, &kMatrix1));
    FPDFPage_InsertObject(page, text_object1);
    EXPECT_TRUE(FPDFPage_GenerateContent(page));
    {
    diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
    index dc0f8a2..b060a1a 100644
    --- a/fpdfsdk/fpdf_editpage.cpp
    +++ b/fpdfsdk/fpdf_editpage.cpp
    @@ -652,7 +652,8 @@
    CFX_Matrix cmatrix = CFXMatrixFromFSMatrix(*matrix);
    switch (pPageObj->GetType()) {
    case CPDF_PageObject::TEXT:
    - return false;
    + pPageObj->AsText()->SetTextMatrix(cmatrix);
    + break;
    case CPDF_PageObject::PATH:
    pPageObj->AsPath()->set_matrix(cmatrix);
    break;

    2 is the latest approved patch-set. The change was submitted with unreviewed changes in the following files: The name of the file: core/fpdfapi/page/cpdf_textobject.h Insertions: 3, Deletions: 1. ``` @@ -32:33, +32:33 @@ - // CPDF_PageObject + // CPDF_PageObject: @@ +68:69 @@ + // Caller is expected to call SetDirty(true) when done changing the object. @@ +70:71 @@ + ```

    To view, visit change 82614. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic1cd9a5d95a3760da39fd00c1d9d388c1e2aa23d
    Gerrit-Change-Number: 82614
    Gerrit-PatchSet: 4
    Gerrit-Owner: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-MessageType: merged
    Reply all
    Reply to author
    Forward
    0 new messages