RTFchars fix#2097
Conversation
|
looks like i need some more testscases for my changes |
boceckts
left a comment
There was a problem hiding this comment.
Only minor comments from my side.
| } | ||
| } | ||
| //if( <= c && c <= ) | ||
| // return ""; No newline at end of file |
There was a problem hiding this comment.
Remove out commented code.
| return new StringInt(format(res), part.length()); | ||
| } | ||
|
|
||
| private String transformSpecialCharacter(long c) { |
There was a problem hiding this comment.
Please add a javadoc comment.
| return "ss"; | ||
| if(161 ==c) | ||
| return "!"; | ||
| return "?"; |
There was a problem hiding this comment.
I don't like the multiple return statements and no brackets. Please use a variable which gets returned once in the end of the method and use if else with brackets.
There was a problem hiding this comment.
the way it is implemented now, has a better performance 👍
There was a problem hiding this comment.
You can leave the return statements but please add the brackets.
|
What about a switch Statement with case?
|
|
I also thought about switch case, but i came to the conclusion it gets way to big 🎅 |
tobiasdiez
left a comment
There was a problem hiding this comment.
I can't really judge the correctness of your changes (I have no experience with the RTF stuff), thus only a few general comments about the code.
| return "ss"; | ||
| if(161 ==c) | ||
| return "!"; | ||
| return "?"; |
There was a problem hiding this comment.
You can leave the return statements but please add the brackets.
| return "!"; | ||
| return "?"; | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Don't remove newlines at end.
There was a problem hiding this comment.
I'll add the brackets and the newline.
| put("?i", "\\'ed"); | ||
| put("?o", "\\'f3"); | ||
| put("?u", "\\'fa"); | ||
| put("'a", "\\'e1"); |
There was a problem hiding this comment.
Could you please explain the reason for this change (? -> ' )
There was a problem hiding this comment.
Yes sure, later in the RTFCharMap you would find "'a" assigned with unicode, so I thought why not just map it to the RTF value if it already exists.
| // Use UNICODE characters for RTF-Chars which can not be found in the | ||
| // standard codepage | ||
|
|
||
| put("`A", "\\u192A"); // "Agrave" |
There was a problem hiding this comment.
Why did you removed some of these mappings?
There was a problem hiding this comment.
Some keys got 2 values assigned, so I removed the double assignement. If a key got an RTF value I removed the unicode value.
| Assert.assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e {\\u230ae} should be \\u230ae", | ||
| formatter.format("Réflexions sur le timing de la quantité {\\ae} should be æ")); | ||
|
|
||
| Assert.assertEquals("h\\'e1ll{\\u339oe}", formatter.format("h\\'all{\\oe}")); |
There was a problem hiding this comment.
Please only one assert per test method.
There was a problem hiding this comment.
Some test methods inside this test class have lots of assertions for single characters, can I leave it like that? I will split the longer ones like you recommend.
| Assert.assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e {\\u230ae} should be \\u230ae", | ||
| formatter.format("Réflexions sur le timing de la quantité {\\ae} should be æ")); | ||
|
|
||
| Assert.assertEquals("h\\'e1ll{\\u339oe}", formatter.format("h\\'all{\\oe}")); |
There was a problem hiding this comment.
Please only one assert per test method.
|
Code-wise this looks fine for me. Though I'll admit that I have not looked up the mapping table and would trust you on this. I have one more question regarding code style that is not your fault, but could you improve it anyway? I do not like that |
|
I looked the mappings up and the ones in JabRef seemed to be fine, so I used them. I will double check my code at the end to be 100% sure the mappings are fine. Also I will improve the code quality like @lenhard mentioned. |
|
This looks done, or is there something left? @mairdl If so, please merge master into your branch and we are ready to go. |
|
I'm on it. |
# Conflicts: # CHANGELOG.md
|
So can it be merged now? |
|
Yes, thanks for your contribution! |
* upstream/master: (102 commits) Removed unused test code (#2140) Fix main table bug when creating a duplicate (#2135) Remove explicit author and add SPDX-License-Identifier Remove GPL from README.md and CONTRIBUTING.md fix preview update (#2125) Remove some UnicodeToLatex uses (#2132) Fix mixup in french/farsi localization FetcherException should extend JabRefException Fix exception when opening preference dialog (#2127) Unify ParserException and ParseException (#2124) Small refactoring in Importer package (#2053) Implement Datepicker "none"-button (#2122) revert change from 816d30c Change title/tooltip of source panel in biblatex mode (#2120) Refactoring: completey typed metadata and add detailed travis output (#2112) RTFchars fix (#2097) Fix NPE in Medline fetcher on missing ISSN (#2113) Ctrl-s parsing error message (#2114) Fix bad web search error messages (#2034) parse error freeze (#2106) ... # Conflicts: # src/main/java/net/sf/jabref/collab/FileUpdateMonitor.java # src/main/java/net/sf/jabref/gui/externalfiles/DownloadExternalFile.java # src/main/java/net/sf/jabref/gui/externalfiles/DroppedFileHandler.java # src/main/java/net/sf/jabref/gui/externalfiles/MoveFileAction.java # src/main/java/net/sf/jabref/logic/cleanup/RenamePdfCleanup.java # src/main/java/net/sf/jabref/logic/exporter/FileSaveSession.java # src/main/java/net/sf/jabref/logic/util/io/FileUtil.java # src/main/java/net/sf/jabref/preferences/JabRefPreferences.java
* Fix RTFChars * Formatting, correcting wrong expected values * add missing keys and clean up * Improve formatting, fix minor issue * Rework tests to fit, remove @ignore * Remove duplicate keys * Make test fit new keys, add new test for RTFChars * Add additional complicated sentence * add a javadoc, remove unneeded lines * Add brackets to if statements * Split asserts up * use internal HashMap, remove extends HashMap * remove unneeded values * Add changes to CHANGELOG.md
RTFcharsTest had some ignored test. So I looked into it and made the necessery changes. I added some of the tested but missing special characters. I also modified the
expectedandactualvaulues where needed (because to my understanding of this topic, some values were wrong). Since I am not 100% sure if everything is correct, comments are appreciated.Also I added "translator" which takes the unicode and transforms it back into its root letter.
E.g.
é - > \\u233eMy final change is that I removed duplicate keys inside the RTFCharMap.