Hi,
Got a small problem that when I export a TRichViewEdit to xhtml I'm not able to see any images inside a tablecell that has the cursor in it. Any idea how I can fix this?
No exported image when cell is still edited
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hi,
Found a workaround by adding a rve.Delesect() call before saving.
But when I remove this code, it seems like the problem is solved anyway (restructured the GUI). My guess it that it was caused by the editor/cell still having focus when it was streamed. So problem fixed but I can't tell how.
The code used was (I'm saving swf and avi too) and the code is located in a TRvActionEvent (which might be the cause of the problem as the focus is still in the editor when pressed):
Found a workaround by adding a rve.Delesect() call before saving.
But when I remove this code, it seems like the problem is solved anyway (restructured the GUI). My guess it that it was caused by the editor/cell still having focus when it was streamed. So problem fixed but I can't tell how.
The code used was (I'm saving swf and avi too) and the code is located in a TRvActionEvent (which might be the cause of the problem as the focus is still in the editor when pressed):
Code: Select all
procedure T_TaakEditor.DoPreview(rve: TRichViewEdit);
var
ms : TMemoryStream;
sl : TStringList;
html : IXMLDOMDocument;
xslt : IXMLDOMDocument;
begin
ms := TMemoryStream.Create;
sl := TStringList.Create;
rve.Deselect;
rve.OnSaveComponentToFile := rvSaveComponentToFile;
rve.OnSaveImage2 := rvSaveImage2;
rve.OnWriteHyperlink := rvWriteHyperlink;
rve.RVData.Flags := rve.RVData.Flags + [rvflRoot];
rve.SaveHTMLToStreamEx(ms,
_Mainform.MyTempPath,
rve.Name, ChangeFileExt(ExtractFileName(_Mainform.Storage1.FileName), '') + '_', '', '', '',
[rvsoUTF8, rvsoXHTML]);
ms.Seek(0, soFromBeginning);
sl.LoadFromStream(ms);
rve.OnWriteHyperlink := nil;
rve.OnSaveImage2 := nil;
rve.OnSaveComponentToFile := nil;
//some code ommited
end;
Code: Select all
procedure T_TaakEditor.rvSaveComponentToFile(Sender: TCustomRichView;
Path: string; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;
var OutStr: string);
var
scale : string;
urlStr : string;
Panel : TPanel;
Player : TMediaPlayer;
begin
if (SaveMe is TMyShockwaveFlash) and (saveFormat = rvsfHTML) then
begin
OutStr := Sender.RVData.GetNextFileName('', Path, '.swf', FlashCounter, True);
urlStr := 'file://' + StringReplace(OutStr, '\', '/', [rfReplaceAll]);
TMyShockwaveFlash(SaveMe).SaveFlash(OutStr);
case TMyShockwaveFlash(SaveMe).ScaleMode of
0: scale := 'ShowAll';
1: scale := 'NoBorder';
else
scale := 'ExactFit';
end;
OutStr := Format('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
'codebase="http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0" ' +
'width=%d height=%d>' +
'<PARAM NAME="Quality" VALUE="high">' +
'<PARAM NAME="Menu" VALUE="False">' +
'<PARAM name="Movie" value="%s">' +
'<PARAM name="Play" value="True">' +
'<PARAM name="Scale" value="%s">' +
'<PARAM name="Loop" value="True">' +
'<EMBED src="%s" Quality=high swLiveConnect=FALSE Menu=FALSE WIDTH=%d HEIGHT=%d ' +
'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
'</EMBED></OBJECT>',
[TMyShockwaveFlash(SaveMe).Width, TMyShockwaveFlash(SaveMe).Height,
urlStr, scale,
urlStr, TMyShockwaveFlash(SaveMe).Width, TMyShockwaveFlash(SaveMe).Height]);
end;
if (SaveMe is TPanel) and (saveFormat = rvsfHTML) then
begin
Panel := SaveMe as TPanel;
Player := Panel.Components[1] as TMediaPlayer;
urlStr := Player.FileName; //veg:was ExtractRelativePath(Path, Player.FileName);
urlStr := 'file://' + StringReplace(urlStr, '\', '/', [rfReplaceAll]);
OutStr := Format(
'<object type="video/avi" width="%d" height="%d">' +
'<param name="filename" value="%s" />' +
'<a href="%s">Video</a>' +
'</object>',
[Panel.Width, Panel.Height, urlStr, urlStr]);
end;
end;
Code: Select all
procedure T_TaakEditor.rvWriteHyperlink(
Sender: TCustomRichView; id: Integer; RVData: TCustomRVData;
ItemNo: Integer; SaveFormat: TRVSaveFormat; var Target, Extras: string);
begin
Target := PChar(RVData.GetItemTag(ItemNo));
if (Pos('http://', LowerCase(Target)) = 0) then
Target := 'http://' + Target;
end;
Code: Select all
procedure T_TaakEditor.rvSaveImage2(Sender: TCustomRichView; Graphic: TGraphic;
SaveFormat: TRVSaveFormat; const Path, ImagePrefix: string; var
ImageSaveNo: Integer; var Location: string; var DoDefault: Boolean);
begin
Location := Sender.RVData.SavePicture(SaveFormat, ImagePrefix, Path, ImageSaveNo, True,
clWhite, Graphic);
Location := 'file://' + StringReplace(Path + Location, '\', '/', [rfReplaceAll]);
DoDefault := False;
end;
Dear Sergey,
I've noticed the same problem when a tablecell contains an image and the cursor is still there, the image could not be taken. I think the problem is in the 'OnSaveImage2'-event. I use this event for converting the 'Graphic' to a 'MIMEEncodeString' for sending as an e-mail.
[edit] Adding 'rve->Deselect();' at the beginning of my source gives a solution, like Wim van der Vegt suggested. [/edit]
Pieter E.
I've noticed the same problem when a tablecell contains an image and the cursor is still there, the image could not be taken. I think the problem is in the 'OnSaveImage2'-event. I use this event for converting the 'Graphic' to a 'MIMEEncodeString' for sending as an e-mail.
[edit] Adding 'rve->Deselect();' at the beginning of my source gives a solution, like Wim van der Vegt suggested. [/edit]
Pieter E.