Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return table start PDPage from drawer #115

Merged
merged 3 commits into from
Jan 30, 2021

Conversation

grasshopper7
Copy link

Attempt to solve issue 114. - #114.

Copy link
Owner

@vandeseer vandeseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor things should be changed before merging.
Thanks for your PR! 👍

pageToDrawOn = pageSupplier.get();
document.addPage(pageToDrawOn);
} else
pageToDrawOn = document.getPage(document.getNumberOfPages() - 1);
pageToDrawOn = document.getPage(document.getNumberOfPages() - 1);
Copy link
Owner

@vandeseer vandeseer Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add brackets around the bodies of if s and else s. This is a general recommendation. It's very easy to make mistakes on refactorings and it's pretty simple to prevent 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@@ -139,11 +155,15 @@ public void draw(Supplier<PDDocument> documentSupplier, Supplier<PDPage> pageSup

protected PDPage determinePageToDraw(int index, PDDocument document, Supplier<PDPage> pageSupplier) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the returned value used at all? So either return the value and assign it where it is called (preferably) or just make the method void.

Copy link
Author

@grasshopper7 grasshopper7 Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returned PDPage is used by the draw(Supplier documentSupplier, Supplier pageSupplier, float yOffset) method. Not sure I got your suggestion.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my bad. You are right. Still, there is a thing which I don't like about this method and which should be easy to fix: There is a side effect, namely setting the member variable tableStartPage within the method. At the same time this value is returned. Since it is called only once one could argue that it would make more sense to set the member variable after the method is called using its returned value.

(There is a 2nd side effect nonetheless though which is setting the member variable startTableInNewPage – but the fewer side effects the better in my opinion.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point taken. Have moved both the if conditions into the parent draw method.

@vandeseer vandeseer merged commit 13edb90 into vandeseer:develop Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants