?
Solved

Storing Rich Text

Posted on 2001-06-29
6
Medium Priority
?
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

764 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