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