Skip to content

Support HTML as a Clipboard format for StyledText (issue #292) - #395

Merged
mickaelistria merged 7 commits into
eclipse-platform:masterfrom
mihnita:master
Sep 19, 2022
Merged

mickaelistria merged 7 commits into
eclipse-platform:masterfrom
mihnita:master

Conversation

@mihnita

@mihnita mihnita commented Sep 18, 2022 •

Copy link
Copy Markdown
Contributor

See https://mihai-nita.net/eclipse_clip_html/ for a small test app, and screenshots of the results.

I've tested on Windows 11 against Firefox (opening the html file), GMail in Chrome, and MS Word 2010.

Need to do:

  • more testing in other applications, on Windows, MacOS and Linux
  • unit tests (I would appreciate some advice on what is would be the best way to test this)
  • maybe push it to support a bit more

What I know might use some work

  • wrap indent (not supported). The model between SWT and CSS are quite different, so indent, wrap indent, margin, interact in "funny ways"
  • line spacing not supported (again, padding margin interference)
  • Empty paragraphs need to be <p>&nbsp;</p> instead of <p></p>

But I think it already supports more than the RTF clipboard format.

Thanks,
Mihai

@github-actions

github-actions Bot commented Sep 18, 2022 •

Copy link
Copy Markdown
Contributor

Unit Test Results

     602 files       602 suites   12m 38s ⏱️
  4 019 tests   4 011 ✔️     5 💤 3 ❌
24 058 runs  23 916 ✔️ 134 💤 8 ❌

For more details on these failures, see this check.

Results for commit d6eb617.

♻️ This comment has been updated with latest results.

@mickaelistria

Copy link
Copy Markdown
Contributor

@mihnita

mihnita commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

Ah, got it!

The test registers a addLineStyleListener(listener) which counts the processed lines in linesCalled[0], then calls text.copy()

There are 6 lines, and copy used to call LineStyleListener for each line to get the styles when saving the RTF.
Now it does the exact same thing for the HTML. And that doubles the number of calls from 6 to 12.

Fixed, sorry.


Q.: how can I run the tests from command line?
I only manage to do it from Eclipse.
But command line I've tried mvn install and mvn verify from all kind of folders.

The error is:

[ERROR]   The project eclipse.platform.swt:eclipse.platform.swt:4.26.0-SNAPSHOT (D:\EclipseDev\swt-master\git\eclipse.platform.swt\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for eclipse.platform.swt:eclipse.platform.swt:4.26.0-SNAPSHOT: Could not find artifact org.eclipse:eclipse-platform-parent:pom:4.26.0-SNAPSHOT and 'parent.relativePath'
 points at wrong local POM @ line 16, column 11 -> [Help 2]

I suspect I've missed a project in eclipse-installer

Thank you,
M.

@mickaelistria

Copy link
Copy Markdown
Contributor

To run from CLI, you usually need to add -Pbuild-individual-bundles to your Maven command-line so it can reference the parent pom and other stuff.

@mihnita

mihnita commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

OK, I see another failure, but I don't know if that is related.

java.lang.AssertionError: expected:<85> but was:<170>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:647)
	at org.junit.Assert.assertEquals(Assert.java:633)
	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_StyledText.test_caretSizeAndPositionVariableGlyphMetrics(Test_org_eclipse_swt_custom_StyledText.java:4882)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Running it in Eclipse it passes just fine, and checking the code does not have anything to do with the clipboard.
But the doubling (170 = 185 x 2) is weirdly similar to the previous failure, which was caused by my code.
It might still be a coincidence, but it's weird one.
That one was easy to explain, this one is not :-(

What do you think?


Running command line seems to work, but with the wrong swt version.
It looks like my changes are not there (the tests are, but not the changes in code, adding html).

And if I @Ignore the HTML test(s) there is another one failing:

Tests run: 7, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 s <<< FAILURE! - in org.eclipse.swt.tests.junit.Test_org_eclipse_swt_SWT
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_SWT.test_isLocal  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: Tested SWT is signed by Eclipse: (SWT='C:/Users/mihai/.m2/repository/p2/osgi/bundle/org.eclipse.swt.win32.win32.x86_64/3.121.100.v20220915-0515/org.eclipse.swt.win32.win32.x86_64-3.121.100.v20220915-0515.jar' signer='1.2.840.113549.1.9.1=#16157765626d61737465724065636c697073652e6f7267,CN=Eclipse.org Foundation\, Inc.,OU=IT,O=Eclipse.org Foundation\, Inc.,L=Ottawa,ST=Ontario,C=CA')

Which seems to confirm that the tests are running with a downloaded swt, not my local one.
Probably some version wrong in some manifest or pom.xml.


Thanks,
M.

@mickaelistria

Copy link
Copy Markdown
Contributor

org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_StyledText.test_caretSizeAndPositionVariableGlyphMetrics(Test_org_eclipse_swt_custom_StyledText.java:4882)

This one is not related and is already tracked in #294

@mickaelistria
mickaelistria merged commit aaffb08 into eclipse-platform:master Sep 19, 2022
@mickaelistria

Copy link
Copy Markdown
Contributor

Thank you!

@mihnita

mihnita commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

Thank you!
M.

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.

2 participants