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

More RTL Support for Xlsx/Html Comments #4065

Merged
merged 3 commits into from
Jun 11, 2024

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented Jun 6, 2024

Following up from PR #4006. There is an additional RTL property available. It controls the placement of bidirectional neutral characters (mainly punctuation), as opposed to strong (alphabetic characters) or weak (numeric characters), especially at the beginning or end of a line. The new Comment property textboxDirection will be used for that purpose.

In a discussion in issue #4004 following the implementation of the PR, the comment was mixed RTL and LTR, and this led to some formatting problems. The user was able to overcome these with the timely insertion of Unicode directional control characters, but it would be preferable to have it happen automatically, which this change will permit. However, the use of these control characters cannot be entirely done away with. In the new test case, if one of the all-English lines ended with, say, a colon, it would not display correctly; LRM (left-to-right mark) after the colon would be needed. Likewise, one or two of the comment lines with mixed RTL and LTR (discussed in the issue) is not formatted correctly, and might require LRO/PDF or equivalent.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Why this change is needed?

Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.

Following up from PR PHPOffice#4006. There is an additional RTL property available. It controls the placement of bidirectional neutral characters (mainly punctuation), as opposed to strong (alphabetic characters) or weak (numeric characters), especially at the beginning or end of a line. The new Comment property textboxDirection will be used for that purpose.

In a discussion in issue PHPOffice#4004 following the implementation of the PR, the comment was mixed RTL and LTR, and this led to some formatting problems. The user was able to overcome these with the timely insertion of Unicode directional control characters, but it would be preferable to have it happen automatically, which this change will permit. However, the use of these control characters cannot be entirely done away with. In the new test case, if one of the all-English lines ended with, say, a colon, it would not display correctly; LRM (left-to-right mark) after the colon would be needed. Likewise, one or two of the comment lines with mixed RTL and LTR (discussed in the issue) is not formatted correctly, and might require LRO/PDF or equivalent.
@berberon
Copy link

berberon commented Jun 7, 2024

How would a line of code using textboxDirection look like?

@oleibman
Copy link
Collaborator Author

oleibman commented Jun 7, 2024

See testIssue4004td in the new test members that are part of this PR.

@berberon
Copy link

berberon commented Jun 7, 2024

I'm sorry,

I don't understand what you means by "See testIssue4004td in the new test members that are part of this PR."

@oleibman
Copy link
Collaborator Author

oleibman commented Jun 7, 2024

There is a clickable "Files Changed" items at the top of this page. If you click on that, you'll see all the code that is changing with this PR. At the very bottom of the page, you'll see CommentAlignmentTest.php, and that has a method testIssue4004td, which demonstrates the use of setTextboxDirection.

@berberon
Copy link

berberon commented Jun 8, 2024

Hi,

I really appreciate your patience and your willingness to explain. It's truly valued.

So instead of :

	$objPHPExcel->getActiveSheet()->getComment('A1')->getText()->createTextRun(**"\u{202E}"** . $SettingsStamp);
	$objPHPExcel->getActiveSheet()->getComment('A1')->setAlignment(Alignment::HORIZONTAL_RIGHT);

I will be able to do :

	$objPHPExcel->getActiveSheet()->getComment('A1')->getText()->createTextRun($SettingsStamp);
	$objPHPExcel->getActiveSheet()->getComment('A1')->setAlignment(Alignment::HORIZONTAL_RIGHT);
        $objPHPExcel->getActiveSheet()->getComment('A1')->**setTextboxDirection(Comment::TEXTBOX_DIRECTION_RTL);**

I have been waiting years for such an option and it will certainly be appreciated by out excel users :)

@oleibman oleibman enabled auto-merge June 11, 2024 13:25
@oleibman oleibman added this pull request to the merge queue Jun 11, 2024
Merged via the queue into PHPOffice:master with commit 60baa3a Jun 11, 2024
12 of 13 checks passed
@oleibman oleibman deleted the issue4004td branch June 11, 2024 13:35
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.

2 participants