kooloveme / thtmlviewer

Automatically exported from code.google.com/p/thtmlviewer
Other
0 stars 0 forks source link

FindSourcePos returns incorrect value #300

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to migrate from a pre-unicode version of HTMLViewer and I am facing 
a problem with FindSourcePos. It does not return the correct position. It seems 
it returns a position ahead of the correct position.

Original issue reported on code.google.com by emau...@gmail.com on 3 Sep 2013 at 11:26

GoogleCodeExporter commented 9 years ago
Thanks for spotting this issue.

Could you please post a simple example (file) to reproduce it?

Thanks in advance.
OrphanCat

Original comment by OrphanCat on 16 Nov 2013 at 3:42

GoogleCodeExporter commented 9 years ago
Hi OrphanCat,

Unfortunately, it is not possible. I use HTMLViewer in my program called
ConnectedText. I use an old version of HTMLViewer.. I tried to upgrade to
the latest version of HTMLViewer but it was not possible due the problem I
mentioned. CT generates HTML files on the fly and display them using
HTMLViewer. Files are generated UTF-8 encoded.

Original comment by emau...@gmail.com on 17 Nov 2013 at 11:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hello,

I am facing a very similar problem after migrating to Delphi XE4.
After some code research I think, that one line in unit ReadHTML.pas is causing 
this:

unit: ReadHTML.pas (revision 480)
line: 282

function ReadChar: ThtChar;
begin
  repeat
    if DocStack.Count = 0 then
      // update document position only for outmost document
      PropStack.SIndex := Doc.Position; // <-!-!-!-!-!-! sholdn't Doc.Position be divided by 2, since Doc is an 2-Byte-char buffer?
    Result := Doc.NextChar;
    if (Result = EofChar) and DocStack.AtLeast(1) then
    begin
      Doc.Free;
      Doc := DocStack.Pop;
    end
    else
      break;
  until false;

  if not LinkSearch and (PropStack.Document <> nil) then
  begin
    Inc(CharCount);
    if (Result = EofChar) or (CharCount and $FFF = 0) {about every 4000 chars} then
      if Doc.Size > 0 then
        THtmlViewerBase(CallingObject).htProgress((Doc.Position * PropStack.Document.ProgressStart) div Doc.Size);
  end;
end;

Original comment by renehoff...@googlemail.com on 11 Aug 2014 at 2:55