You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Axel Howind (Jira)" <ji...@apache.org> on 2024/02/15 11:06:00 UTC

[jira] [Comment Edited] (PDFBOX-5769) Duplicated code in interactive.annotation.layout and interactive.form

    [ https://issues.apache.org/jira/browse/PDFBOX-5769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17817635#comment-17817635 ] 

Axel Howind edited comment on PDFBOX-5769 at 2/15/24 11:05 AM:
---------------------------------------------------------------

I have created a [PR|https://github.com/apache/pdfbox/pull/185] for this:

* I have moved the classes from `org.apache.pdfbox.pdmodel.interactive.annotation.layout` to `org.apache.pdfbox.pdmodel.interactive` and changed the code to use these new classes instead of the ones in both `org.apache.pdfbox.pdmodel.interactive.annotation.layout` and `org.apache.pdfbox.pdmodel.interactive.form`. 
* I have removed the now empty package `org.apache.pdfbox.pdmodel.interactive.annotation.layout`.
* I have removed the duplicated classes from `org.apache.pdfbox.pdmodel.interactive.form`.
* I checked the differences between both versions of the classes. They had diverged in two aspects:
  * The PlainText constructor in `org.apache.pdfbox.pdmodel.interactive.form` checked if the supplied `textContent` was empty and if so just created an empty paragraph whereas the class in `org.apache.pdfbox.pdmodel.interactive.annotation.layout` would create a paragraph containing a single space. Creating an empty paragraph for the special case of en empty textContent looks reasonable to me, so I copied that code over.
  * The Paragraph classes have diverged in that the one in the forms package used some more sophisticated code for splitting lines. That looked good for me, so I copied that over too. In case the difference is important, please give some feedback so that I can update the pacth accordingly. But it looked rather like an improvement/bugfix was made to the code in the forms package and simply not applied to the other copy.



was (Author: axh):
I have created a PR for this:

* I have moved the classes from `org.apache.pdfbox.pdmodel.interactive.annotation.layout` to `org.apache.pdfbox.pdmodel.interactive` and changed the code to use these new classes instead of the ones in both `org.apache.pdfbox.pdmodel.interactive.annotation.layout` and `org.apache.pdfbox.pdmodel.interactive.form`. 
* I have removed the now empty package `org.apache.pdfbox.pdmodel.interactive.annotation.layout`.
* I have removed the duplicated classes from `org.apache.pdfbox.pdmodel.interactive.form`.
* I checked the differences between both versions of the classes. They had diverged in two aspects:
  * The PlainText constructor in `org.apache.pdfbox.pdmodel.interactive.form` checked if the supplied `textContent` was empty and if so just created an empty paragraph whereas the class in `org.apache.pdfbox.pdmodel.interactive.annotation.layout` would create a paragraph containing a single space. Creating an empty paragraph for the special case of en empty textContent looks reasonable to me, so I copied that code over.
  * The Paragraph classes have diverged in that the one in the forms package used some more sophisticated code for splitting lines. That looked good for me, so I copied that over too. In case the difference is important, please give some feedback so that I can update the pacth accordingly. But it looked rather like an improvement/bugfix was made to the code in the forms package and simply not applied to the other copy.


> Duplicated code in interactive.annotation.layout and interactive.form
> ---------------------------------------------------------------------
>
>                 Key: PDFBOX-5769
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5769
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 4.0.0
>            Reporter: Axel Howind
>            Priority: Minor
>
> I just stumbled upon lots of duplicated code in those two packages that I think should be cleaned up. As that would mean users would have to change imports, that would be a change for a major version. I will prepare a PR for this to suggest some changes that you can review and comment.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org