13 Commits

Author SHA1 Message Date
oleibman 455f1129bf RTL Text Alignment in Xlsx Comment
Fix #4004. RTL text can be included in a comment, and will display correctly, but the comment as a whole will be left-aligned. There already exists an `alignment` property for Comment, but it is unused. This PR will allow that property to be set, and to be read from and written to an Xlsx spreadsheet when possible.

The Xml tags that govern this property are found, unusually, in a drawing Vml file. The important property is `x:TextHAlign`, which can be set to Left, Right, Center, Justified, or Distributed. There are other tags which seemed like they were relevant to this problem, but I don't think they actually matter:
```xml
  <v:textbox style='mso-direction-alt:auto'>
   <div style='text-align:right;direction:rtl'></div>
  </v:textbox>
```
2024-04-30 22:22:03 -07:00
oleibman d0fae3f57a Eliminate Some Phpstan Annotations (#3746)
* Eliminate Some Phpstan Annotations

Some changes are possible due to Php8+ features like null-safe operators and Stringable.

* Possible Uninitialized Variable

Scrutinizer might be technically correct.

* CellAddress Static -> Self

I don't understand the use case for extending it, which would be the reason for using static rather than self.

* Update Worksheet.php
2023-09-30 08:48:02 -07:00
Adrien Crivelli ec4098c8fd Strict mode for all tests
While we might never be able to have 100% of our code strict, we can at
the very least do it for all of our tests. This ensures that our tests
are using our API with the types as intended by the test author, and not
silently be cast to what our API requires.
2023-09-07 17:44:56 +08:00
oleibman 58c6e51992 Sync composer.lock/.json and Phpstan Upgrade (#3212)
* Sync composer.lock/.json and Phpstan Upgrade

For some reason, a version newly cloned from master receives a complaint from composer that the lock and json files aren't in sync. So I ran composer update. The only thing that needs special attention is, as usual, Phpstan. There are an unusually large number of new differences when Phpstan is run with Php7.4 vs Php8.1. These are handled easily enough. But Reader/Xlsx seems very fragile; a change which would have eliminated one of the new errors seems to have caused Phpstan to go into a loop, as does an annotation without a code change, and, indeed, as does just about any change to that member. This bears watching, and it's a reason I will delay installing this.

* Deleting Phpstan Cache Helps

It lets me change Reader/Xlsx as I wished. Not a great resolution, but probably good enough. I will continue to think about it for a couple of days.

* Minor DocBlock Changes

Correct some PhpDocumentor problems.
2022-11-27 07:39:24 -08:00
MarkBaker 4d2b00dafc phpcs fxes 2022-06-14 12:19:54 +02:00
Dams 7f62fba7ef Update the method testRemoveComment
Adding test to check if comment exists before delete it
2022-06-14 10:44:42 +02:00
Dams 52da0dc0fc Add use PhpOffice\PhpSpreadsheet\Spreadsheet; 2022-06-09 09:18:48 +02:00
Dams 56ddbc4dd5 Add testRemoveComment 2022-06-09 09:08:52 +02:00
oleibman ad5532e2f4 Namespacing Phase 2 - Styles (#2471)
* WIP Namespacing Phase 2 - Styles

This is part 2 of a several-phase process to permit PhpSpreadsheet to handle input Xlsx files which use unexpected namespacing. The first phase, introduced as part of release 1.19.0, essentially handled the reading of data. This phase handles the reading of styles. More phases are planned.

It is my intention to leave this in draft status for at least a month. This will give time for additional testing, by me and, I hope, others who might be interested.

This fixes the same problem addressed by PR #2458, if it reaches mergeable status before I am ready to take this out of draft status. I do not anticipate any difficult merge conflicts if the other change is merged first.

This change is more difficult than I'd hoped. I can't get xpath to work properly with the namespaced style file, even though I don't have difficulties with others. Normally we expect:
```xml
<stylesheet xmlns="http://whatever" ...
```
In the namespaced files, we typically see:
```xml
<x:stylesheet xmlns:x="http://whatever" ...
```

Simplexml_load_file specifying a namespace handles the two situations the same, as expected. But, for some reason that I cannot figure out, there are significant differences when xpath processes the result. However, I can manipulate the xml if necessary; I'm not proud of doing that, and will gladly accept any suggestions. In the meantime, it seems to work.

My major non-standard unit test file had disabled any style-related tests when phase 1 was installed. These are now all enabled.

* Scrutinizer

Its analysis is wrong, but the "errors" it pointed out are easy to fix.

* Eliminate XML Source Manipulation

Original solution required XML manipulation to overcome what appears to be an xpath problem. This version replaces xpath with iteration, eliminating the need to manipulate the XML.

* Handle Some Edge Cases

For example, Style file without a Fills section.

* Restore RGB/ARGB Interchangeability

Fix #2494. Apparently EPPlus outputs fill colors as `<fgColor rgb="BFBFBF">` while most output fill colors as `<fgColor rgb="FFBFBFBF">`. EPPlus actually makes more sense. Regardless, validating length of rgb/argb is a recent development for PhpSpreadsheet, under the assumption that an incorrect length is a user error. This development invalidates that assumption, so restore the previous behavior.

In addition, a comment in Colors.php says that the supplied color is "the ARGB value for the colour, or named colour". However, although named colors are accepted, nothing sensible is done with them - they are passed unchanged to the ARGB value, where Excel treats them as black. The routine should either reject the named color, or convert it to the appropriate ARGB value. This change implements the latter.
2022-02-11 06:42:04 -08:00
MarkBaker 0502fd3e7f Size validator for comment dimensions and margins 2020-11-02 21:24:27 +01:00
MarkBaker 93fe84da71 Additional unit tests 2020-11-02 20:14:44 +01:00
MarkBaker 3a960d62a6 Remember return typehints for unit tests 2020-11-02 15:16:40 +01:00
MarkBaker 5e4288958c Additional unit tests for comments 2020-11-02 14:55:28 +01:00