OOTest.pp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {***********************************************************************
  2. *
  3. * $RCSfile: SampleUI.pas,v $
  4. *
  5. * $Revision: 1.2 $
  6. *
  7. * last change: $Author: hr $ $Date: 2003/06/30 15:51:41 $
  8. *
  9. * The Contents of this file are made available subject to the terms of
  10. * the BSD license.
  11. *
  12. * Copyright (c) 2003 by Sun Microsystems, Inc.
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions
  17. * are met:
  18. * 1. Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
  24. * contributors may be used to endorse or promote products derived
  25. * from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  30. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  31. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  33. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  34. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  35. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  36. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  37. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. *************************************************************************}
  40. {$mode objfpc}
  41. uses
  42. OOHelper;
  43. var
  44. Sample : TSampleCode;
  45. procedure error(const s : string = 'Error');
  46. begin
  47. writeln(s);
  48. halt(1);
  49. end;
  50. begin
  51. write('Connection to StarOffice ... ');
  52. Sample := TSampleCode.Create();
  53. if Sample.Connect() then
  54. writeln('done.')
  55. else
  56. error;
  57. write('Creating new text document ... ');
  58. if Sample.CreateDocument(false) then
  59. writeln('done.')
  60. else
  61. error;
  62. {
  63. try
  64. writeln('Inserting Table ...');
  65. Sample.InsertTable(Edit2.Text, Edit1.Text);
  66. writeln('Ready');
  67. except
  68. Error;
  69. end;
  70. }
  71. write('Disconnection from StarOffice ... ');
  72. Sample.Disconnect();
  73. writeln('done.');
  74. writeln('Finished');
  75. end.
  76. {
  77. end;
  78. procedure TOKBottomDlg.OnCreateDocument(Sender: TObject);
  79. begin
  80. end;
  81. procedure TOKBottomDlg.OnInsertTable(Sender: TObject);
  82. begin
  83. end;
  84. procedure TOKBottomDlg.OnGetDatabasePointer(Sender: TObject);
  85. var
  86. res : String;
  87. begin
  88. try
  89. StatusBar1.SimpleText := 'Getting database pointer ...';
  90. res := Sample.getDatabasePointer(Edit4.Text, Edit3.Text);
  91. Application.MessageBox(PAnsiChar('the pointer: ' + res), PAnsiChar('Result'), ID_OK);
  92. StatusBar1.SimpleText := 'Ready';
  93. except
  94. StatusBar1.SimpleText := 'Error';
  95. end;
  96. end;
  97. procedure TOKBottomDlg.OnGetCellContent(Sender: TObject);
  98. var
  99. res : String;
  100. begin
  101. try
  102. StatusBar1.SimpleText := 'Getting cell content ...';
  103. res := Sample.getCellContent(Edit6.Text);
  104. Application.MessageBox(PAnsiChar('the content: ' + res), PAnsiChar('Result'), ID_OK);
  105. StatusBar1.SimpleText := 'Ready';
  106. except
  107. StatusBar1.SimpleText := 'Error';
  108. end;
  109. end;
  110. end.
  111. }