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