TRvHtmlImporter doesnt transfer list

General TRichView support forum. Please post your questions here
Post Reply
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

TRvHtmlImporter doesnt transfer list

Post by Jim Knopf »

hi,
for the investigation tool in Patchwork I can copy html pages to clipboard and insert the clipboards content via TRvHtmlImporter.
It works fine but it doesn't transfer list items properly. They are side by side instead of among each other:

Image

what didn't I consider?

Thank you
Martin
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I can only suggest trying TrvHtmlViewImporter instead, sorry.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

Unfortunately I am not able to import Text including pictures (links) with TrvHtmlViewImporter. TrvHtmlViewImporter crashes because of not accessable file address 'http://... .jpg'

TRvHtmlImporter and rvHTMLImageRequired2 where I can get the image via HTTPGet. That works fine except the mentioned problem with list styles.

My current solution is:

Code: Select all

for I := rv.ItemCount-1 downto 0 do
begin
  ...
  rvConcept.GetItem(I).ItemOptions := rvConcept.GetItem(I).ItemOptions - [rvioSameAsPrev];
end;
That's not perfect but better then before. I only hope that not many cases with eligible rvioSameAsPrev occur.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It does not crash, this is a handled exception, it is noticeable only when debugging the application in Delphi IDE.
To download remote images, instead of using the HTML importer's event, use TRichView.OnImportPicture. This is an universal event, it happens when importing RTF with external pictures, and when using rvHtmlViewImporter, and when using rvHtmlImporter.

The code that you implemented makes all item start from a new line, it is not good.

I do not know what's special with the lists on your page. If you sent me this page, I can try to see what's wrong with it. But:
- rvHtmlImporter may have much more problems, it supports only basic HTML, rvHtmlViewImporter is much-much better
- we do not plan to improve rvHtmlImporter, because we plan to write our own HTML import procedure from scratch
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

I followed your suggestion but had more problems as before.

The normal import seems nice with simple sites. The result with Wikipedia is more ugly then with TRvHtmlImporter : New line for each new Item that includes rvioSameAsPrev.

Next trouble: There is an Option in Patchwork to append other sites to the same TRichViewEdit (Flag 'Ctrl'). No problem with TRvHtmlImporter because of the property ClearDocument = False. So I need with TRVHTMLViewImporter to import for additionals sites into another TRichViewEdit and append its content to the regular. But:

1. Save and Load RTF works, but with bad formatting
2. Save and Append RVF crashes at the rvConcept.Format (shown below) or, if I use TStream instead, at SaveRVFToStream

Code: Select all

Screen.Cursor := crHourGlass;
if KeyHit(VK_CONTROL) then
begin
  rvConcept.AddNL('', 0, 0);
  rvConcept.AddNL(cSepar, 0, 0);           // '- - - - - - -'
  rvConcept.AddNL('', 0, 0);
end
else
  rvConcept.Clear;
try
  if not Ctrl then
    RvHTMLVi.LoadFromClipboard(rvConcept, HTMLViewer1)
  else
  begin
    RvHTMLVi.LoadFromClipboard(rvTemp, HTMLViewer1);
    // append
    Stream := T(String)Stream.Create('');
    try
      rvTemp.SaveRVFToStream(Stream, False);          // < ---------- c r a s h (TStream)
      rvTemp.Format;
      Stream.Position := 0;
      rvConcept.AppendRVFFromStream(Stream, -1);
      rvConcept.Format;                                         // < ---------- c r a s h (TStringStream)
    finally
      Stream.Free;
    end;
  end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be you forgot to remove your code that clears "sameasprev" flag?

To add to the end of existing document, use RvHtmlViewImporter.AppendHtmlViewer
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As for crashes, use TMemoryStream instead of TStream
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

Hey Sergey,

you are right - as always :-) - both of your tipps brought the solution!
Thank you for answering my questions so carefully!

Works fine! One last (I hope) question: I copy a web site to the clipboard, click on the import button - perfect now (if not Ctrl then-branch). Than I copy another site to the clipboard and append it (Flag 'Ctrl'): the previous clipboard content is appended again. Does that depend on the BasePath parameter of AppendHtmlViewer? If yes, how is it to be supplied?

I tried this code:

Code: Select all

if not Ctrl then
  RvHTMLVi.LoadFromClipboard(rvConcept, HTMLViewer1)
else
begin
  HTMLViewer1.Clear;             // 1)
  RvHTMLVi.LoadFromClipboard(nil, HTMLViewer1);    // 2)
  RVHTMLVi.AppendHtmlViewer(HTMLViewer1, rvConcept);
end;
1) only this: clears - nothing importet
2) GPF
If I leave away 1) and 2) the behaviour is as mentioned above.


Absolutely independent of that all:

HAPPY NEW YEAR!
and thank you for your great components and support!


Martin
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

found a solution - a liite slower but it works:

Code: Select all

if not Ctrl then
  RvHTMLVi.LoadFromClipboard(rvConcept, HTMLViewer1)
else
begin
  RvHTMLVi.LoadFromClipboard(rvTemp, HTMLViewer1);   // <----
  RVHTMLVi.AppendHtmlViewer(HTMLViewer1, rvConcept);
end;
So it doesn't override the existing content of rvConcept.
Post Reply