Skip to content

Add editAs Property for 2-cell Anchor Drawings#2674

Merged
oleibman merged 3 commits intoPHPOffice:masterfrom
oleibman:twocelleditas2
Mar 16, 2022
Merged

Add editAs Property for 2-cell Anchor Drawings#2674
oleibman merged 3 commits intoPHPOffice:masterfrom
oleibman:twocelleditas2

Conversation

@oleibman
Copy link
Collaborator

@oleibman oleibman commented Mar 13, 2022

This change builds on PR #2532 (@naotake51 as PR #2532), using ideas from PR #2237 (@AdamGaskins), which has had changes requested for several months. It covers a lot of the same ground as 2532. In Excel, two-cell anchor drawings can be edited as "twocell", "onecell", or "absolute". This PR adds support for those options, with a sample file that demonstrates the difference in addition to unit tests. Several other tests are added to improve the spotty coverage for Drawings.

There have been several other tickets referencing two cell anchors, including issue #1159 and PR #1160 (@sgarwood, who also added support for editAs), PR #643, and issue #126, all now closed but not necessarily entirely resolved. I will try to ensure that those tickets are addressed with this one.

And, in trying to make sure 1160 is covered, I stumbled upon a bug. If you use the same image resource to create two+ memory drawings, the MemoryDrawing destructor for the first will cause the rest to generate a very long warning message. This is not a problem for Php8+, only for Php7-. I have suppressed the message in the MemoryDrawing constructor. 1160 went stale due to an unresolved test error, but I don't think this was the problem. At any rate, its test works now.

This is:

- [ ] a bugfix
- [x] a new feature

Checklist:

Why this change is needed?

This change builds on PR PHPOffice#2532 (@naotake51 as PR PHPOffice#2532), using ideas from PR PHPOffice#2237 (@AdamGaskins), which has had changes requested for several months. It covers a lot of the same ground as 2532. In Excel, two-cell anchor drawings can be edited as "twocell", "onecell", or "absolute". This PR adds support for those options, with a sample file that demonstrates the difference in addition to unit tests. Several other tests are added to improve the spotty coverage for Drawings.

There have been several other tickets referencing two cell anchors, including issue PHPOffice#1159 and PR PHPOffice#1160 (@sgarwood, who also added support for editAs), PR PHPOffice#643, and issue PHPOffice#126, all now closed but not necessarily entirely resolved. I will try to ensure that those tickets are addressed with this one.

And, in trying to make sure 1160 is covered, I stumbled upon a bug. If you use the same image resource to create two+ memory drawings, the MemoryDrawing destructor for the first will cause the rest to generate a very long warning message. This is not a problem for Php8+, only for Php7-. I have suppressed the message in the MemoryDrawing constructor. 1160 went stale due to an unresolved test error, but I don't think this was the problem. At any rate, its test works now.
It reported 1 minor issue (fixed normally), and 2 major. One is fixed with a kludge. The other is a case where Scrutinizer's analysis is just wrong, and I can't figure out a kludge. But I was able to add an annotation (the first time I've managed to get one past phpcs/php-cs-fixer). We'll see.
@oleibman
Copy link
Collaborator Author

I shall ignore the remaining Scrutinizer problem. I added one try/catch block to test some uncovered code, and that dropped that particular method's complexity from B to C, which is apparently a fail for Scrutinizer. Doing nothing about it seems entirely appropriate.

@oleibman oleibman merged commit 9428552 into PHPOffice:master Mar 16, 2022
@oleibman oleibman deleted the twocelleditas2 branch April 18, 2022 14:38
@oleibman oleibman mentioned this pull request Oct 13, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant