Solved

Storing Rich Text

Posted on 2001-06-29
6
310 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
Independent Software Vendors: 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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