In patron card creator, layouts can define up to three lines of text to print to the card. When the text of a line is too long, wrapping will happen. If the wrapped text contains a word that is repeated at least once in the string, the words in the text can be rearranged, the repeated words being grouped together. To reproduce, I use the following text that I put in a card layout : "one two three one two three one two three one two three one two three one two three one two three one two three" I then export some patron cards using this layout. In the resulting file, the words are all out of order : all of the ones appear first, followed by all the twos and only then the threes. The problem is that wrapping happens by finding the last word that can be cut from the string and putting it in a new line. But, when the word is then removed from the original text, only the first occurrence is removed if it appears more than once. The new last word to be removed from the end of the line is the same word again and again until there is none left. We should make sure to remove the word at the end of the line, exactly where we found it to start with.
Created attachment 92411 [details] [review] Bug 23488: Line wrapping doesn't always respect word order in Patron card creator When wrapping long lines of text, the line is divided by removing each word from the end of the line and putting it in a new one until the line is the right width. When the word to be removed appears multiple time in the line, it is not the last occurrence that is removed. This patch changes the regular expression used to remove the part of the text that is wrapped to a new line, making sure it removes it at the end of the text. Test plan: 1. Go to Tools > Patron card creator 2. Have a card template and a card batch -> If needs be, you can create them by using New > Card template or New > Card batch 3. Create a layout and use one text field containing a long text with at least one word which is repeated a minimum of 2 times (preferably towrdds the end of the text, since it has to be picked as one of the words to appear in the new line). You can use this: one two three one two three one two three one two three one two three one two three one two three one two three ... 4. Go to Manage > Card batches and export a batch 5. Choose the layout set up in 3. 6. Click the Export button and open the resulting pdf file 7. Notice all the repeated word have been grouped -> For this example : all of the ones appear first, followed by all the twos and only then the threes. 8. Apply patch 9. Repeat step 4 through 7 => this time the order of the words has not changed!
Created attachment 97030 [details] [review] Bug 23488: Line wrapping doesn't always respect word order in Patron card creator When wrapping long lines of text, the line is divided by removing each word from the end of the line and putting it in a new one until the line is the right width. When the word to be removed appears multiple time in the line, it is not the last occurrence that is removed. This patch changes the regular expression used to remove the part of the text that is wrapped to a new line, making sure it removes it at the end of the text. Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com>
Created attachment 97059 [details] [review] Bug 23488: Line wrapping doesn't always respect word order in Patron card creator When wrapping long lines of text, the line is divided by removing each word from the end of the line and putting it in a new one until the line is the right width. When the word to be removed appears multiple time in the line, it is not the last occurrence that is removed. This patch changes the regular expression used to remove the part of the text that is wrapped to a new line, making sure it removes it at the end of the text. Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com> Signed-off-by: William Frazilien <william.frazilien@inlibro.com>
Created attachment 99115 [details] [review] Bug 23488: Line wrapping doesn't always respect word order in Patron card creator When wrapping long lines of text, the line is divided by removing each word from the end of the line and putting it in a new one until the line is the right width. When the word to be removed appears multiple time in the line, it is not the last occurrence that is removed. This patch changes the regular expression used to remove the part of the text that is wrapped to a new line, making sure it removes it at the end of the text. Test plan: 1. Go to Tools > Patron card creator 2. Have a card template and a card batch -> If needs be, you can create them by using New > Card template or New > Card batch 3. Create a layout and use one text field containing a long text with at least one word which is repeated a minimum of 2 times (preferably towrdds the end of the text, since it has to be picked as one of the words to appear in the new line). You can use this: one two three one two three one two three one two three one two three one two three one two three one two three ... 4. Go to Manage > Card batches and export a batch 5. Choose the layout set up in 3. 6. Click the Export button and open the resulting pdf file 7. Notice all the repeated word have been grouped -> For this example : all of the ones appear first, followed by all the twos and only then the threes. 8. Apply patch 9. Repeat step 4 through 7 => this time the order of the words has not changed! Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Work as described, no errors. Tested adding addrees to test layout, and using the proposed text.
Readded the 2 sign-off lines that got lost when the test plan was added to the commit message (thx for that Bernardo!)
Created attachment 99835 [details] [review] Bug 23488: Line wrapping doesn't always respect word order in Patron card creator When wrapping long lines of text, the line is divided by removing each word from the end of the line and putting it in a new one until the line is the right width. When the word to be removed appears multiple time in the line, it is not the last occurrence that is removed. This patch changes the regular expression used to remove the part of the text that is wrapped to a new line, making sure it removes it at the end of the text. Test plan: 1. Go to Tools > Patron card creator 2. Have a card template and a card batch -> If needs be, you can create them by using New > Card template or New > Card batch 3. Create a layout and use one text field containing a long text with at least one word which is repeated a minimum of 2 times (preferably towrdds the end of the text, since it has to be picked as one of the words to appear in the new line). You can use this: one two three one two three one two three one two three one two three one two three one two three one two three ... 4. Go to Manage > Card batches and export a batch 5. Choose the layout set up in 3. 6. Click the Export button and open the resulting pdf file 7. Notice all the repeated word have been grouped -> For this example : all of the ones appear first, followed by all the twos and only then the threes. 8. Apply patch 9. Repeat step 4 through 7 => this time the order of the words has not changed! Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com> Signed-off-by: William Frazilien <william.frazilien@inlibro.com> Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Work as described, no errors. Tested adding addrees to test layout, and using the proposed text. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Nice work everyone! Pushed to master for 20.05
Pushed to 19.11.x branch for 19.11.05
backported to 19.05.x for 19.05.10
Minor patch will not be backported to 18.11.x series.