Page 1 of 1

Save and Lod from DB table and various other questions

Posted: Mon Mar 24, 2014 11:56 am
by TonyBlom
I have a few questions relating to SR actionTestRibbonTab

I really like the look and feel and it has 99% of the functionality I want. I have added to it the ability to insert controls based on the InsertControls Demo It works.

1. I have no experience at the Ribbon. How do add a band and items ? Is there an step by step explanation ?
2. I wish to save my Doc to a Database table.
i. My field for the RVF is nVarChar(MAX) Is this OK ?
ii. Save and Load from DB table. Can you provide sample code of saving it to the DB and loading it back from the DB please. I tried for some hours to do it with streams but could not get it to work. I tried many different ways from various group postings but none of them work.
3. Id like to add compression. Is there anyway built into RVF to do compression or packed binary storage ?
Thanks very much,

Tony

Posted: Tue Mar 25, 2014 8:10 pm
by Sergey Tkachenko
1. I suggest to google "Delphi TRibbon tutorial"
2. No, Unicode-text field cannot store RVF. varbinary should be used.
Probably, your problems were because of incorrect field type.
The functions are below. But instead of them, you can simply use TDBSRichViewEdit.

Code: Select all

function SaveRVFToField(srv: TSRichViewEdit; tbl: TDataSet; const FieldName: String): Boolean;
var Stream: TStream;
begin
  Stream := tbl.CreateBlobStream(tbl.FieldByName(FieldName), bmWrite);
  try
    Result := srv.RichViewEdit.SaveRVFToStream(Stream, False);
  finally
    Stream.Free;
  end;
end;
 
function LoadRVFFromField(srv: TSRichViewEdit; tbl: TDataSet; const FieldName: String): Boolean;
var Stream: TStream;
begin
  Stream := tbl.CreateBlobStream(tbl.FieldByName(FieldName), bmRead);
  try
    Result := srv.RichViewEdit.LoadRVFFromStream(Stream);
  finally
    Stream.Free;
  end;
  srv.Format;
end;
3. TRichView itself does not provide methods for compression. You can use other compression tools. For example, you can pack using ZLib (included in Delphi), see the help file on TZCompressionStream and TZDecompressionStream.

Posted: Wed Mar 26, 2014 6:42 am
by TonyBlom
Thanks Sergey. Got it all figured out. I have reverted to using the Action test Demo instead until I have mastered Ribbons and your actions.

Do you have a version of the ActionRibbon Demo without Tabs ?

Posted: Thu Mar 27, 2014 11:47 am
by Sergey Tkachenko
Sorry, no, there is only a tabbed version of TRibbon demo.