Page 1 of 1
TRvHtmlImporter doesnt transfer list
Posted: Wed Dec 23, 2015 9:22 pm
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:
what didn't I consider?
Thank you
Martin
Posted: Thu Dec 24, 2015 8:56 am
by Sergey Tkachenko
I can only suggest trying TrvHtmlViewImporter instead, sorry.
Posted: Mon Dec 28, 2015 7:00 pm
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.
Posted: Wed Dec 30, 2015 10:58 am
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
Posted: Thu Dec 31, 2015 11:09 am
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;
Posted: Thu Dec 31, 2015 4:55 pm
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
Posted: Thu Dec 31, 2015 6:11 pm
by Sergey Tkachenko
As for crashes, use TMemoryStream instead of TStream
Posted: Thu Dec 31, 2015 9:29 pm
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
Posted: Fri Jan 01, 2016 7:56 am
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.