Solved

Storing Rich Text

Posted on 2001-06-29
6
305 Views
Last Modified: 2010-04-06
Currently I am using a OLE object to initiate a Word Document.  Once this is launched the user types it's information and then from there needs to post it info to a database (rich text and all).  Is there any way you can store rich text in a record and be able to retrieve it in that same format back into an OLE object?  I know you can use a TDBRichEdit but for my purposes it doesn't have the functionality that Microsoft Word does.  What data type do you use in ORACLE to store the data?  And is there a way you can insert directly from the OLE object?

Thanks
0
Comment
Question by:nkrueger
6 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6237919
TDBRichEdit is made for this purpose...
0
 
LVL 1

Expert Comment

by:trex_fire
ID: 6238457
What are the functionnalities the DBRichEdit won't offer you??
0
 

Author Comment

by:nkrueger
ID: 6238493
I need the capability to use auto text, auto corrects, the ability to add specific dictionary terms (in my case medical terms), etc.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:edey
ID: 6238621
Also, richEdit is really a kind of markedup text (sorta like html).  if you display richtext in a memo you'll get all kinds of "extra" char's - but you _can_ display & edit it.  Load it into a richEdit & you'll get formatted text.  In short you should be ok to save the resulting richText as plain text - just be shure to use a richText capable control to display it.

GL
Mike
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6240606
you can use a blob field in oracle and store the worddocument as is there

you can use ole or shellexecute(needs a file) to let edit the serverapplication the content
(which, must be stored also in the db)

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6240618
a bit older sample (provided by simonet) using ole with paradox as database,
but this may applyable to all databases,
which are provding blobs,
even it supports any ole-serverapplication

unit uOleDbMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtnrs, ExtCtrls, Db, DBTables, DBCtrls, ComCtrls, ToolWin, Grids,
  DBGrids, ImgList;

type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    Panel2: TPanel;
    Panel3: TPanel;
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    DBNavigator1: TDBNavigator;
    Table1: TTable;
    DataSource1: TDataSource;
    Splitter1: TSplitter;
    ScrollBox1: TScrollBox;
    OleContainer1: TOleContainer;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ImageList1: TImageList;
    DBGrid1: TDBGrid;
    OpenDialog1: TOpenDialog;
    Table1Description: TStringField;
    Table1OriginalFileName: TStringField;
    Table1FileTypeDescription: TStringField;
    Table1OleData: TBlobField;
    Table1OleClassName: TStringField;
    procedure OleContainer1ObjectMove(OleContainer: TOleContainer;
      const Bounds: TRect);
    procedure Table1NewRecord(DataSet: TDataSet);
    procedure FormResize(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure OleContainer1Deactivate(Sender: TObject);
    procedure Table1AfterScroll(DataSet: TDataSet);
  private
     function IsObjectEmpty : boolean;
    procedure SaveFileToBlob(fName : string);
    procedure LoadOLE;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses ShellAPI;

procedure TForm1.OleContainer1ObjectMove(OleContainer: TOleContainer;
  const Bounds: TRect);
begin
  OleContainer1Deactivate(self);
end;

procedure TForm1.Table1NewRecord(DataSet: TDataSet);
begin
  OleContainer1.DestroyObject;

end;

procedure TForm1.LoadOLE;
var
  bs : TBlobStream;
begin
  if table1.fieldbyname('OleClassName').asstring<>'' then
  begin
     bs := TblobStream.create(Table1OleData, bmRead);
     try
        OleContainer1.CreateObject(table1.fieldbyname('OleClassName').asstring, false);
        OleContainer1.LoadFromStream(bs);
     finally
        bs.free;
     end;
  end;
end;


procedure TForm1.FormResize(Sender: TObject);
begin
  OleContainer1.Top := 0;
  OleContainer1.Left := 0;
end;

procedure TForm1.SaveFileToBlob(fName : string);
var
  bs : TBlobStream;
  sh : TSHFileInfo;
begin
  SHGetFileInfo(pchar(fNAme), 0, sh, sizeof(sh), SHGFI_TYPENAME );
  Table1.FieldByName('FileTypeDescription').asstring := sh.szTypeName;
  Table1.FieldByName('OriginalFileName').asstring := fName;
  Table1.FieldByName('OleClassName').asstring := OleContainer1.OleClassName;
  bs := TBlobStream.Create(Table1OleData, bmWrite      );
  Olecontainer1.SaveToStream(bs);
  bs.free;
  exit;
end;


procedure TForm1.ToolButton1Click(Sender: TObject);
var
  fName : string;
begin
 if IsObjectEmpty then
 begin
     if OpenDialog1.Execute then
     begin
        fName := uppercase(ExpandFileName(OpenDialog1.FileName));
        OleContainer1.CreateObjectFromFile(fName, false);
        OleContainer1.Top := 0;
        OleContainer1.left := 0;
     end;
     with Table1 do
     begin
        try
           edit;
        except
           append;
        end;
        SaveFileToBlob(fName);
        while OleContainer1.State<>osLoaded do
           application.processMessages;
        post;
     end;
  end;
end;

function TForm1.IsObjectEmpty : boolean;
begin
  Result := Table1.fieldbyname('OleData').IsNull;
  if (not Result) then
     Result := (Application.messageBox('This record already contains an OLE object. Would you like to overwrite it?', pchar(Application.title), MB_ICONQUESTION + MB_YESNO) = IDYES);
end;

procedure TForm1.OleContainer1Deactivate(Sender: TObject);
var
  bs : tBlobStream;
begin
  Table1.edit;
  bs := TBlobStream.create(Table1OleData, bmWrite);
  Olecontainer1.SaveToStream(bs);
  bs.free;
  Table1.post;
  OleContainer1.Top := 0;
  OleContainer1.Left := 0;
end;

procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
begin
  try
    LoadOLE;
  except
    // do nothing
  end;
end;

end.

meikl ;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now