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

Add a way to set graphics in a header/footer #2018

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

imirkin
Copy link
Contributor

@imirkin imirkin commented Nov 3, 2024

The full functionality of the VML drawing is not addressed here. However this seems to work for embedding regular images.

PR Details

Adds the ability to set header/footer graphics.

Description

This is a somewhat restricted implementation out of all the options possible. But it's enough to get the basics going, and I doubt anyone out there wants too much more than this offers -- image + width/height for scaling.

If this function is called twice, it won't "update" the existing bits, but rather just leave them around and make a new drawing / media image. I don't think there's any process to "GC" the left-overs, but it's also not completely clear what to do about this. The media object may be shared by multiple drawings / sheets that have the same image.

How Has This Been Tested

This is based on what MS Excel produces. I tried other variations but was mostly unsuccessful. I had some variations which produced a border (without using the formulas bit), and many which crashed Excel -- seems like the logic to processing these is a bit fragile. Not 100% sure what all is needed since there are a lot of permutations, but with everything I have, it seems to work OK.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I wasn't too sure how to test the change, so I added an example.

The full functionality of the VML drawing is not addressed here. However
this seems to work for embedding regular images.
@xuri xuri added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 4, 2024
@xuri xuri linked an issue Nov 4, 2024 that may be closed by this pull request
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.20%. Comparing base (0d5d1c5) to head (e735fdd).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2018   +/-   ##
=======================================
  Coverage   99.20%   99.20%           
=======================================
  Files          32       32           
  Lines       29803    29880   +77     
=======================================
+ Hits        29565    29642   +77     
  Misses        158      158           
  Partials       80       80           
Flag Coverage Δ
unittests 99.20% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

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

Thanks for your PR. I updated unit tests and simplify code based on your code. Much appreciated.

@imirkin
Copy link
Contributor Author

imirkin commented Nov 4, 2024

Great. I wasn't 100% sure about the API, and I couldn't come up with a good Get variant. But I think it's still useful without that. I thought about putting it into the SetHeaderFooter call, but since there's no good way to Get it, I decided against it. Happy to iterate on the API if you think it still needs work though.

@xuri xuri merged commit b7375bc into qax-os:master Nov 4, 2024
41 checks passed
@xuri
Copy link
Member

xuri commented Nov 4, 2024

Thanks for your contribution. I merged this PR. If you'd like to add GetLegacyDrawingHF function, that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Features
Development

Successfully merging this pull request may close these issues.

Header Image
2 participants