Solved

Storing Rich Text

Posted on 2001-06-29
6
309 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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