On Sun, Feb 21, 2010 at 9:33 AM, James McKenzie jjmckenzie51@earthlink.net wrote:
This is how I calculated the value to be the same as that returned by EM_FORMATRANGE when run in Windows(whatever). If you have a better method, that would be great.
I have a better method, it is returning textlength + 1 in this case, because this is the behaviour that native riched20 has for this case. I have sent you patches plenty of times, so you know what I think is the correct code for this case. Attached is a patch that changes you code to what I think it should be for handling this issue.
The wrapping issue should be handled as a separately.
As I have mentioned to you before in an offlist email, this will cause problems with applications which try to print all the pages in a loop with cpMax=-1 to specify to print to the end of the text, and cpMin for following calls set to the return value of preview calls to send EM_FORMATRANGE messages. The return value will cause an endless loop for long enough text with more characters than the width of the page in twips.
Hmm. This is not something that I have tested, nor is there a test in riched20 for this. Do you think this should have a test case?
What I provided was the most severe realistic test case I could think of, and I previously provided you a sample rtf file and a patch that shows the behaviour in wordpad.
The automated tests are not very extensive, so I have attached a patch for the automated tests that adds two very simple test cases.