BerndGabriel / HtmlViewer

The well-known Delphi/Lazarus HtmlViewer/FrameViewer
Other
395 stars 147 forks source link

Bug and fix when copying text. #195

Open larsa9000 opened 7 years ago

larsa9000 commented 7 years ago

Hello

Copying text on some html files don't works. Nothing is copied.

I fixed it with the following changes:

procedure TCellBasic.CopySelectedText; var I: Integer; SLE, SLB: Integer; begin if not Assigned(Document) then Exit; {dummy cell} SLB := Document.SelB; SLE := Document.SelE; if SLE <= SLB then Exit; {nothing to do}

// * Old code *** // for I := 0 to Count - 1 do // with Items[I] do // begin // if (SLB >= StartCurs + Len) then // Continue; // if (SLE <= StartCurs) then // Break; // CopySelectedText; // end; // End old code ****

// * New code *** for I := 0 to Count - 1 do begin if (SLB >= StartCurs + Len) then Continue; if (SLE <= StartCurs) then Break; Items[I].CopySelectedText; end; // End new code **** end;

procedure TSection.CopySelectedText; var I, Strt, X1, X2: Integer; MySelB, MySelE: Integer; // * New code *** Ok: boolean; // End new code ** begin // * New code ** Ok := False; // * End new code ****

MySelB := Document.SelB - StartCurs; MySelE := Document.SelE - StartCurs; for I := 0 to Lines.Count - 1 do begin with Lines.Items[I] do begin Strt := Start - Buff; if (MySelE <= Strt) or (MySelB > Strt + Ln) then Continue; if MySelB - Strt > 0 then X1 := MySelB - Strt else X1 := 0; if MySelE - Strt < Ln then X2 := MySelE - Strt else X2 := Ln; if (I = Lines.Count - 1) and (X2 = Ln) then Dec(X2); Document.CB.AddText(Start + X1, X2 - X1); // * New code *** // Something was copied. Possibly add CR. Ok := True; // End new code **** end; end;

// * Old code *** // if MySelE > Len then // Document.CB.AddTextCR('', 0); // End old code ****

// * New code *** if Ok and (MySelE > Len) then Document.CB.AddTextCR('', 0); // End new code **** end;

Regards,

Lars Arvidsson

BerndGabriel commented 6 years ago

Thanks for spotting this issue and the possible correction.

I have 2 questions:

1) Could you please post one or some example HTML document/s, that is/are copied correctly only with your modifications so I can see what's going wrong with the current code? Thank you.

The current logic that uses Items[i].StartCurs and Items[i].Len via "with" in function TCellBasic.CopySelectedText looks correct.

2) TSection.CopySelectedText is modified only as the new code might call TSection.CopySelectedText although there is nothing to copy or is it another issue?

larsa9000 commented 6 years ago

Hello

The problematic HTML file is attached. I did not look trough the code very much, I did just a quick fix that solved the problem.

I also noticed that double clicking a word will not select it. Selecting by dragging with the mouse works.

Regards,

Lars Arvidsson, Axolot Data www.axolot.com

Thanks for spotting this issue and the possible correction.

I have 2 questions:

1) Could you please post one ore some example HTML document/s, that is/are copied correctly only with your modifications so I can see what's going wrong with the current code? Thank you.

The current logic that uses Items[i].StartCurs and Items[i].Len via "with" in function TCellBasic.CopySelectedText looks correct.

2) TSection.CopySelectedText is modified only as the new code might call TSection.CopySelectedText although there is nothing to copy or is it another issue?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/BerndGabriel/HtmlViewer/issues/195#issuecomment-348765080

BerndGabriel commented 6 years ago

if www.axolot.com is the attached file, which compiler and operation system and which version of HtmlViewer do you use? HtmlViewer/FrameBrowzer compiled with Delphi XE5 on Windows 10 seems to work well on it. Also the operating system's code page could be of interest. Okay, content of www.axolot.com hints to "almost any Delphi" and Windows ;)

larsa9000 commented 6 years ago

Hello

www.axolot.com is NOT the attached file. Do you have another email address where I can send it to? Your github reply to address looks really strange, and mail sent to it probably passes trough some kind of filter.

Regards,

Lars Arvidsson, Axolot Data www.axolot.com

if www.axolot.com is the attached file, which compiler and operation system and which version of HtmlViewer do you use? HtmlViewer/FrameBrowzer compiled with Delphi XE5 on Windows 10 seems to work well on it. Also the operating system's code page could be of interest. Okay, content of www.axolot.com hints to "almost any Delphi" and Windows ;)

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/BerndGabriel/HtmlViewer/issues/195#issuecomment-349058897

BerndGabriel commented 6 years ago

OrphanCat

BerndGabriel commented 6 years ago

at

BerndGabriel commented 6 years ago

gmail.com