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