Basic Programmer's Guide Staroffice[TM] 7
Total Page:16
File Type:pdf, Size:1020Kb
StarOfficeTM 7 Office Suite A SunTM ONE Software Offering Basic Programmer's Guide Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. 650-960-1300 Part No. 817-1826-10 July 2003, Revision A Copyrights and Trademarks Copyright © 2003 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054. , U.S.A. All rights reserved. Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries. This document and the product to which it pertains are distributed under licenses restricting their use, copying, distribution, and decompilation. No part of the product or of this document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Third-party software, including font technology, is copyrighted and licensed from Sun suppliers. This product is based in part on the work of the Independent JPEG Group and The FreeType Project. Portions Copyright 2000 SuSE, Inc. Word for Word Copyright © 1996 Inso Corp. International CorrectSpell spelling correction system Copyright © 1995 by Lernout & Hauspie Speech Products N.V. All rights reserved. Sun, Sun Microsystems, the Sun logo, Java, Solaris, StarOffice, the Butterfly logo, the Solaris logo, and the StarOffice logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. UNIX is a registered trademark in the U.S. and in other countries, exclusively licensed through X/Open Company, Ltd. Screen Beans and Screen Beans clipart characters are registered trademarks of A Bit Better Corporation. Federal Acquisitions: Commercial Software - Government Users Subject to Standard License Terms and Conditions. DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. Copyright © 2003 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, Etats-Unis. Tous droits réservés. Sun Microsystems, Inc. a les droits de propriété intellectuels relatants à la technologie incorporée dans ce produit. En particulier, et sans la limitation, ces droits de propriété intellectuels peuvent inclure un ou plus des brevets américains énumérés à http://www.sun.com/patents et un ou les brevets plus supplémentaires ou les applications de brevet en attente dans les Etats - Unis et les autres pays. Ce produit ou document est protégé par un copyright et distribué avec des licences qui en restreignent l'utilisation, la copie, la distribution, et la décompilation. Aucune partie de ce produit ou document ne peut être reproduite sous aucune forme, par quelque moyen que ce soit, sans l'autorisation préalable et écrite de Sun et de ses bailleurs de licence, s'il y ena. Le logiciel détenu par des tiers, et qui comprend la technologie relative aux polices de caractères, est protégé par un copyright et licencié par des fournisseurs de Sun. Ce produit repose en partie sur le travail de l’Independent JPEG Group et de The FreeType Project. Portions Copyright 2000 SuSE, Inc. Word for Word Copyright © 1996 Inso Corp. Système de correction orthographique International CorrectSpell Copyright © 1995 de Lernout & Hauspie Speech Products N.V. Tous droits réservés. Sun, Sun Microsystems, le logo Sun, Java, Solaris, StarOffice, le logo Butterfly, le logo Solaris et le logo StarOffice sont des marques de fabrique ou des marques déposées de Sun Microsystems, Inc. aux Etats-Unis et dans d'autres pays. UNIX est une marque déposée aux Etats-Unis et dans d'autres pays et licenciée exlusivement par X/Open Company, Ltd. Les Screen Beans et les objets graphiques prédessinés Screen Beans sont des marques déposées de A Bit Better Corporation. Acquisitions fédérales : logiciel commercial ; les utilisateurs gouvernementaux sont soumis aux conditions générales standard de la licence. LA DOCUMENTATION est fournie « TELLE QUELLE » et TOUTES LES CONDITIONS, REPRÉSENTATIONS ET GARANTIES EXPRESSES OU TACITES, Y COMPRIS TOUTE GARANTIE TACITE CONCERNANT LA QUALITÉ MARCHANDE, L'APTITUDE À UN USAGE PARTICULIER OU LA NON-VIOLATION DE DROITS DE TIERS SERONT REJETÉES, EXCEPTÉ DANS LE CAS OÙ L'EXCLUSION OU LA LIMITATION DE TELLES GARANTIES NE SERAIT PAS AUTORISÉE PAR LA LÉGISLATION EN VIGUEUR. Contents 1 Introduction 9 About StarOffice Basic 9 Intended Users of StarOffice Basic 10 Use of StarOffice Basic 10 Structure of This Guide 10 More Information 11 2 The Language of StarOffice Basic 13 An Overview of a StarOffice Basic Program 13 Program Lines 13 Comments 14 Markers 15 Working With Variables 15 Implicit Variable Declaration 15 Explicit Variable Declaration 16 Strings 17 From a Set of ASCII Characters to Unicode 17 String Variables 18 Specification of Explicit Strings 18 Numbers 19 Integer Variables 19 Long Integer Variables 19 Single Variables 20 Double Variables 20 Currency Variables 20 Specification of Explicit Numbers 20 True and False 23 Boolean Variables 23 Date and Time Details 23 Date Variables 23 Data Fields 24 3 Simple Arrays 24 Specified Value for Start Index 25 Multi-Dimensional Data Fields 25 Dynamic Changes in the Dimensions of Data Fields 25 Scope and Life Span of Variables 27 Local Variables 27 Public Domain Variables 28 Global Variables 28 Private Variables 29 Constants 30 Operators 30 Mathematical Operators 30 Logical Operators 30 Comparison Operators 31 Branching 31 If...Then...Else 31 Select...Case 32 Loops 33 For...Next 33 Do...Loop 35 Programming Example: Sorting With Embedded Loops 36 Procedures and Functions 37 Procedures 37 Functions 37 Terminating Procedures and Functions Prematurely 38 Passing Parameters 39 Optional Parameters 40 Recursion 41 Error Handling 41 The On Error Instruction 41 The Resume Command 42 Queries Regarding Error Information 42 Tips for Structured Error Handling 43 3 The Runtime Library of StarOffice Basic 45 Conversion Functions 45 Implicit and Explicit Type Conversions 45 Checking the Content of Variables 47 Strings 49 Working with Sets of Characters 49 Accessing Parts of a String 49 4 StarOffice™ 7 Basic Programmer's Guide Search and Replace 50 Formatting Strings 51 Date and Time 52 Specification of Date and Time Details within the Program Code 52 Extracting Date and Time Details 53 Retrieving System Date and Time 54 Files and directories 54 Administering Files 55 Writing and Reading Text Files 59 Message and Input Boxes 60 Displaying Messages 60 Input Box For Querying Simple Strings 62 Other functions 62 Beep 62 Shell 62 Wait 63 Environ 63 4 Introduction to the StarOffice API 65 Universal Network Objects (UNO) 65 Properties and Methods 66 Properties 66 Methods 67 Module, Services and Interfaces 67 Tools for Working with UNO 68 The supportsService Method 68 Debug Properties 68 API Reference 69 An Overview of a Few Central Interfaces 69 Creating Context-Dependent Objects 69 Named Access to Subordinate Objects 70 Index-Based Access to Subordinate Objects 71 Iterative Access to Subordinate Objects 72 5 Working with StarOffice Documents 73 The StarDesktop 73 Basic Information about Documents in StarOffice 74 Creating, Opening and Importing Documents 75 Document Objects 77 Templates 81 Details about various formatting options 82 Contents 5 6 Text Documents 85 The Structure of Text Documents 85 Paragraphs and Paragraph Portions 86 Editing Text Documents 94 The TextCursor 94 Searching for Text Portions 98 Replacing Text Portions 101 Text Documents: More than Just Text 102 Tables 103 Text Frames 107 Text Fields 110 Bookmarks 114 7 Spreadsheet Documents 115 The Structure of Table-Based Documents (Spreadsheets) 115 Spreadsheets 115 Rows and Columns 116 Cells 119 Formatting 123 Editing Spreadsheet Documents Efficiently 133 Cell Ranges 133 Searching and Replacing Cell Contents 135 8 Drawings and Presentations 137 The Structure of Drawings 137 Pages 137 Elementary Properties of Drawing Objects 139 An Overview of Various Drawing Objects 148 Editing Drawing Objects 155 Grouping Objects 155 Rotating and Shearing Drawing Objects 156 Searching and Replacing 157 Presentations 158 Working With Presentations 158 9 Diagrams (Charts) 159 Using Diagrams in Spreadsheets 159 The Structure of Diagrams 160 The Individual Elements of a Diagram 160 Example 166 3D Diagrams 167 6 StarOffice™ 7 Basic Programmer's Guide Stacked Diagrams 167 Diagram Types 167 Line Diagrams 167 Area Diagrams 168 Bar Diagrams 168 Pie Diagrams 168 10 Database Access 169 SQL: a Query Language 169 Types of Database Access 170 Data Sources 170 Queries 171 Links with Database Forms 173 Database Access 174 Iteration of Tables 174 Type-Specific Methods for Retrieving Values 176 The ResultSet Variants 176 Methods for Navigation in ResultSets 177 Modifying Data Records 178 11 Dialogs 179 Working With Dialogs 179 Creating Dialogs 179 Closing Dialogs 181 Access to Individual Control Elements 181 Working With the Model of Dialogs and Control Elements 182 Properties 182 Name and Title 182 Position and Size 182 Focus and Tabulator Sequence 183 Multi-Page Dialogs 183 Events 185 Parameters 187 Mouse Events 188 Keyboard Events 189 Focus Events 190 Control Element-Specific