1*cdf0e10cSrcweir {***********************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  *  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir  *  the BSD license.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir  *  All rights reserved.
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  *  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir  *  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir  *  are met:
12*cdf0e10cSrcweir  *  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir  *  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir  *     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir  *     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir  *     from this software without specific prior written permission.
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir  *
33*cdf0e10cSrcweir  *************************************************************************}
34*cdf0e10cSrcweir unit SampleUI;
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir interface
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
39*cdf0e10cSrcweir   Buttons, ExtCtrls, SampleCode, ComCtrls;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir type
42*cdf0e10cSrcweir   TOKBottomDlg = class(TForm)
43*cdf0e10cSrcweir     Bevel1: TBevel;
44*cdf0e10cSrcweir     Button1: TButton;
45*cdf0e10cSrcweir     Button2: TButton;
46*cdf0e10cSrcweir     Button3: TButton;
47*cdf0e10cSrcweir     Button4: TButton;
48*cdf0e10cSrcweir     Edit1: TEdit;
49*cdf0e10cSrcweir     Label1: TLabel;
50*cdf0e10cSrcweir     Edit2: TEdit;
51*cdf0e10cSrcweir     Label2: TLabel;
52*cdf0e10cSrcweir     Button5: TButton;
53*cdf0e10cSrcweir     Button6: TButton;
54*cdf0e10cSrcweir     Edit3: TEdit;
55*cdf0e10cSrcweir     Label3: TLabel;
56*cdf0e10cSrcweir     Label4: TLabel;
57*cdf0e10cSrcweir     Label6: TLabel;
58*cdf0e10cSrcweir     Edit6: TEdit;
59*cdf0e10cSrcweir     Bevel2: TBevel;
60*cdf0e10cSrcweir     Bevel3: TBevel;
61*cdf0e10cSrcweir     Bevel4: TBevel;
62*cdf0e10cSrcweir     StatusBar1: TStatusBar;
63*cdf0e10cSrcweir     Edit4: TEdit;
64*cdf0e10cSrcweir     Label7: TLabel;
65*cdf0e10cSrcweir     procedure OnConnect(Sender: TObject);
66*cdf0e10cSrcweir     procedure OnDisconnect(Sender: TObject);
67*cdf0e10cSrcweir     procedure OnCreateDocument(Sender: TObject);
68*cdf0e10cSrcweir     procedure OnInsertTable(Sender: TObject);
69*cdf0e10cSrcweir     procedure OnGetDatabasePointer(Sender: TObject);
70*cdf0e10cSrcweir     procedure OnGetCellContent(Sender: TObject);
71*cdf0e10cSrcweir   private
72*cdf0e10cSrcweir     { Private declarations }
73*cdf0e10cSrcweir   public
74*cdf0e10cSrcweir     { Public declarations }
75*cdf0e10cSrcweir   end;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir var
78*cdf0e10cSrcweir   OKBottomDlg: TOKBottomDlg;
79*cdf0e10cSrcweir   Sample : TSampleCode;
80*cdf0e10cSrcweir implementation
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir {$R *.DFM}
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir procedure TOKBottomDlg.OnConnect(Sender: TObject);
85*cdf0e10cSrcweir begin
86*cdf0e10cSrcweir     StatusBar1.SimpleText := 'Connection to StarOffice ...';
87*cdf0e10cSrcweir     Sample := TSampleCode.Create();
88*cdf0e10cSrcweir     if Sample.Connect() then
89*cdf0e10cSrcweir     begin
90*cdf0e10cSrcweir         Button1.Enabled := false;
91*cdf0e10cSrcweir         Button2.Enabled := true;
92*cdf0e10cSrcweir         Button3.Enabled := true;
93*cdf0e10cSrcweir         Button4.Enabled := false;
94*cdf0e10cSrcweir         Button5.Enabled := false;
95*cdf0e10cSrcweir         Button6.Enabled := false;
96*cdf0e10cSrcweir     end;
97*cdf0e10cSrcweir     StatusBar1.SimpleText := 'Ready';
98*cdf0e10cSrcweir end;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir procedure TOKBottomDlg.OnDisconnect(Sender: TObject);
101*cdf0e10cSrcweir begin
102*cdf0e10cSrcweir     StatusBar1.SimpleText := 'Disconnection from StarOffice ...';
103*cdf0e10cSrcweir     Sample.Disconnect();
104*cdf0e10cSrcweir     Button1.Enabled := true;
105*cdf0e10cSrcweir     Button2.Enabled := false;
106*cdf0e10cSrcweir     Button3.Enabled := false;
107*cdf0e10cSrcweir     Button4.Enabled := false;
108*cdf0e10cSrcweir     Button5.Enabled := false;
109*cdf0e10cSrcweir     Button6.Enabled := false;
110*cdf0e10cSrcweir     StatusBar1.SimpleText := 'Ready';
111*cdf0e10cSrcweir end;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir procedure TOKBottomDlg.OnCreateDocument(Sender: TObject);
114*cdf0e10cSrcweir begin
115*cdf0e10cSrcweir     StatusBar1.SimpleText := 'Creating new text document ...';
116*cdf0e10cSrcweir     try
117*cdf0e10cSrcweir         if Sample.CreateDocument(false) then
118*cdf0e10cSrcweir         begin
119*cdf0e10cSrcweir             Button4.Enabled := true;
120*cdf0e10cSrcweir             Button5.Enabled := true;
121*cdf0e10cSrcweir             Button6.Enabled := true;
122*cdf0e10cSrcweir         end;
123*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Ready';
124*cdf0e10cSrcweir     except
125*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Error';
126*cdf0e10cSrcweir     end;
127*cdf0e10cSrcweir end;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir procedure TOKBottomDlg.OnInsertTable(Sender: TObject);
130*cdf0e10cSrcweir begin
131*cdf0e10cSrcweir     try
132*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Inserting Table ...';
133*cdf0e10cSrcweir         Sample.InsertTable(Edit2.Text, Edit1.Text);
134*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Ready';
135*cdf0e10cSrcweir     except
136*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Error';
137*cdf0e10cSrcweir     end;
138*cdf0e10cSrcweir end;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir procedure TOKBottomDlg.OnGetDatabasePointer(Sender: TObject);
141*cdf0e10cSrcweir var
142*cdf0e10cSrcweir     res : String;
143*cdf0e10cSrcweir begin
144*cdf0e10cSrcweir     try
145*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Getting database pointer ...';
146*cdf0e10cSrcweir         res := Sample.getDatabasePointer(Edit4.Text, Edit3.Text);
147*cdf0e10cSrcweir         Application.MessageBox(PChar('the pointer: ' + res), PChar('Result'), ID_OK);
148*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Ready';
149*cdf0e10cSrcweir     except
150*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Error';
151*cdf0e10cSrcweir     end;
152*cdf0e10cSrcweir end;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir procedure TOKBottomDlg.OnGetCellContent(Sender: TObject);
155*cdf0e10cSrcweir var
156*cdf0e10cSrcweir     res : String;
157*cdf0e10cSrcweir begin
158*cdf0e10cSrcweir     try
159*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Getting cell content ...';
160*cdf0e10cSrcweir         res := Sample.getCellContent(Edit6.Text);
161*cdf0e10cSrcweir         Application.MessageBox(PChar('the content: ' + res), PChar('Result'), ID_OK);
162*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Ready';
163*cdf0e10cSrcweir     except
164*cdf0e10cSrcweir         StatusBar1.SimpleText := 'Error';
165*cdf0e10cSrcweir     end;
166*cdf0e10cSrcweir end;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir end.
169