libreoffice basic programming guide pdf

The getByIndex method returns a row object, which supports the com.sun.star.text.TextTableRow service. If UserInput does not contain a valid number, ValidInput is assigned the value 0 and an error message is returned. Using Library.Module variable qualification grants explicit access to module-scoped variables: Constants are values which may be used but not changed by the program. The symbol defined in the corresponding country-specific settings must be used as the decimal point symbol. Example declarations of double variables: Currency variables differ from the other variable types by the way they handle values. The following values are included in this structure: The completed CellRangeAddress structure must be passed as the first parameter to the insertCells method. Public domain variables are defined in the header section of a module by the keyword Dim. They support the following property: The number of the current page can be inserted in a document using the com.sun.star.text.textfield.PageNumber text field. The interface (com.sun.star.sheet.XCellRangeMovement) is available through the spreadsheet object and provides four methods for modifying cell content. Documents can also be created, opened and imported using this service. A table consists of individual rows. The Execute method of the dialog returns the value 0, which is the same as when you click Cancel. A is therefore assigned the string 11. LibreOffice Basic provides two functions to convert lowercase characters in a string to uppercase and vice-versa. To ensure that the footer line is visible, the FooterIsOn property is set to True. If you assign a floating point number to a long integer variable, the number is rounded up or down to the next whole number. Styles deleted from the template are not removed from documents. Even the paragraph properties are available in various objects. They can be displayed as 2D or 3D graphics (com.sun.star.chart.Dim3DDiagram service). The global name ThisComponent generally returns the same object as StarDesktop.CurrentComponent, with one significant advantage. A Draw (or Impress) document is composed of pages, also called slides. It returns the string produced in this way as the result of the replacement process. In the simplest scenario, these are the X and Y-axes. A drawing object for a spreadsheet document, for example, can therefore only exist in conjunction with this one document. In this case, the member PopupTrigger of the event passed to your macro function will be TRUE. Once the Dlg dialog object has been initialized, you can use the Execute method to display the dialog. Most charts in LibreOffice can also be displayed with 3D graphics. Each time the function is called, the values generated previously are not available. The same interface provides methods moveByName and copyByName. You can also edit documents or open databases with event handling as well as access other control elements. If the Dir function finds no more entries, it returns an empty string. While test functions exist for checking numbers, date details and arrays in LibreOffice Basic, a corresponding function for checking Boolean values does not exist. The values for selecting the buttons are: To set a button as the default button, add one of the following values to the parameter value from the list of button selections. However, whether the corresponding settings are based on template or direct formatting in the text is still unclear. To open a PDF document in LibreOffice Draw, simply launch the application and in the menu bar, go to File > Open and then select the PDF document that you want to edit. In so doing, the name of the proper com.sun.star.text.TextFrame service should be specified. This gradually returns the individual paragraphs of the text in a loop. You can also move data from the database window into text documents using the drag-and-drop function. To do this, the function expects a Format expression to be specified, which is then used as the template for formatting the numbers. In the following example the A parameter is obligatory, whereas the B parameter is optional. The more functions a ResultSet provides, the more complex its implementation usually is and therefore the slower the functions are. The text frame is therefore inserted directly in the text flow and behaves like a character. The service term used in LibreOffice Basic therefore corresponds to the type and class terms used in other programming languages. 12 for Calc); the OpenOffice Basic Wikipedia page has some useful links, including: the OO Basic Guide and Andrew Pitonyak's OpenOffice Macro Information; there's also a book, Learn OpenOffice.org Spreadsheet Macro Programming from Pakt . VBA: Whereas VBA summarizes the error messages in a statistical object called Err, LibreOffice Basic provides the Err, Error$, and Erl variables. As can be seen in the example from the previous section, LibreOffice provides a getString method for accessing table contents. The preceding call returns a page object that supports the com.sun.star.drawing.DrawPage service. The following properties are provided for pie and donut charts with the Diagram object: LibreOffice has an integrated database interface (independent of any systems) called Star Database Connectivity (SDBC). Furthermore, it creates a data field for two PropertyValue entries named PrinterProperties. The page properties that are valid for both types of documents are defined in the com.sun.star.style.PageProperties service. A double variable can take up to eight bytes of memory. An example of how to use the definition, and how to reference the fields within an instance, appears in the section on WithEnd With. Most word processing programs now finally provide the option of placing drawing objects, text frames and other objects within a text. storeAsURL provides the following options: The following example shows how the Overwrite option can be used in conjunction with storeAsURL: The example then saves Doc under the specified file name if a file already exists under the name. You will find an overview of the character and paragraph properties available in LibreOffice in the following two sections. This is an object-oriented programming interface which LibreOffice sub-divides into various objects which for their part ensure program-controlled access to the Office package. The Chart object provides the property Area to format the background: The background of a chart covers its complete area, including the area under the title, subtitle and legend. The Assign Action dialog lists all the available Events. As with the loadComponentFromURL method, some options can also be specified in the form of a PropertyValue data field using the storeAsURL method. The following example also shows a correct declaration, but with negative data field limits: It declares an integer data field with 6 values that can be addressed using the indexes -10 to -5. The symbol bars provided by LibreOffice show the common text properties such as font type, weight and size. The start() method of the object is used to start the example and run the screen presentation. The counter is incremented by 1 at the end of each pass. push of a normal button, you can also close an open dialog window with the endExecute method: The dialog object must be accessible from the event routine. Each cell is defined by its X and Y-position with respect to the top left cell which has the position (0,0). You do that by using the name of the object as a qualifier. However, unlike the variable declaration, the array name is followed by parentheses which contain the specifications for the number of elements. The inner loop processes the paragraph portions in these paragraphs. Routine tasks can therefore be automated in LibreOffice Basic, links can be made to other programs for example to a database server and complex activities can be performed at the press of a button by using predefined scripts. The possible values are: In addition to directly modifying cell content, LibreOffice Calc also provides an interface that allows you to insert, delete, copy, or merge cells. The assignment does not need to be placed at the end of the function, but can be made anywhere in the function. The Resume Next command continues the program from the line that follows where the error occurred in the program after the code in the error handler has been executed: Use the Resume Proceed command to specify a jump point for continuing the program after error handling: The term Proceed is a label. Some of the properties that this service provides are: The following example creates a rectangle with a solid border (LineStyle = SOLID) that is 5 millimeters thick (LineWidth) and 50 percent transparent. Functions LBound() and UBound() return respectively the lowest permitted index value and the highest permitted index value of an array. Base uses the HSQLDB database engine to create database documents. Each of these sub-objects contains its own formatting information. When Var is 0, there is a match. To do this, you first create a standard LibreOffice Writer or LibreOffice Calc form and then link the fields to a database. The main properties of this service are described in the following sections. The FileExists function can be used to check whether a file exists: When working with files, it is sometimes important to be able to establish the file properties, the time the file was last changed and the length of the file. The FileLen function determines the length of a file in bytes (as long integer value). So Replace("This is a test", " ", "_") yields "This_is_a_test" :D. Warning: The object variable created must then be initialized so that it can be used. The following parameters can be specified here: The following example is virtually the same as the preceding example, but the Dir function transfers the value 16 as a parameter, which returns the sub-directories of a folder rather than the file names. A TextCursor object is created using the createTextCursor call: The Cursor object created in this way supports the com.sun.star.text.TextCursor service, which in turn provides a whole range of methods for navigating within text documents. To prevent this effect, the user can access the associated paragraph portions rather than the entire paragraph. Functions and procedures can receive one or more parameters. Once the writing process has been completed, the file must be closed using a Close call: Again here, the file handle should be specified. The Diagram object provides the properties Wall and Floor: The specified objects support the com.sun.star.chart.ChartArea service, which provides the usual fill and line properties (com.sun.star.drawing.FillProperties and com.sun.star.drawing.LineProperties services, refer to #Drawings and Presentations). Anyone who has already worked with these languages can quickly become accustomed to LibreOffice Basic. For Windows the recursion level is 5800. The characters are not rotated. As in text documents, drawing documents provide a function for searching and replace. This includes the way in which file names are structured for LibreOffice documents, as well as the format in which files are saved. This status arises, for example, when querying the bold type property of a paragraph, which includes both words depicted in bold and words depicted in normal font. The following call determines the environment variables of the temporary directory of the operating system: LibreOffice objects and methods, such as paragraphs, spreadsheets, and fonts, are accessible to LibreOffice Basic through the LibreOffice application programming interface, or API. Note: For example, this object provides a start method that can start presentations. The gradient starts with red (StartColor) in the top left corner, and extends at a 45 degree angle (Angle) to green (EndColor) in the bottom right corner. The language of LibreOffice Basic: Defines the elementary linguistic constructs, for example, for variable declarations, loops, and functions. For example, the following line declares an array with four integer variables: In the previous examples, the index for the array always begins with the standard start value of zero. If the user changes one of the attributes of a style, then LibreOffice automatically adjusts all document sections depending on the attribute. This represents the content of a complete database table or query. If the directory contains sub-directories or files, these are also deleted. org BASIC Programming Guide This guide provides an introduction to programming with OpenOffice.org Basic. You can also create data sources and work with them using LibreOffice Basic. Example declaration of a Boolean variable: Date variables can contain date and time values. The service recognizes the following properties: If these settings are changed, then all of the pages in the document are affected. The TextCursor object in LibreOffice, for example, provides methods for navigating and changing text which are included in the Range object in VBA (for example, MoveStart, MoveEnd, InsertBefore, InsertAfter). Properties are like the properties of an object; for example, Filename and Title for a Document object. This includes the distance of the paragraph from the edge of the page as well as line spacing. These are useful if no cells have been merged in the table. The following example writes the "Just a Test." The compiler uses the qualifiers from the With as though they were written in front of the partly-qualified name. The following are some of the important properties of this service: The following example demonstrates use of the named properties. The following example sets the page size of a drawing document which has just been opened to 20 x 20 centimeters with a page margin of 0.5 centimeters: Warning: However, this call does not affect the UNO sequences that are defined through the LibreOffice API whose index always begins with 0. If a style in the template has been changed, and you open a document created with that template, you will see a message asking whether to update the styles in the document. The wall is set to be blue. You should also note the difference between text and numbers when you use formulas: Although cell A1 contains the value 100 and cell A2 contains the value 1000, the A1+A2 formula returns the value 100. In the following example, variable I is the loop counter, with an initial value of 1. A Const definition in the module header is available to the code in that module. In LibreOffice, various types of charts can be displayed in a stacked form. If a different chart type is needed, then the bar chart must be explicitly replaced: The first line defines the corresponding chart object. The minimum value of the Y-axis is fixed to 0 and the maximum value is fixed to 100 so that the resolution of the chart is retained even if the values are changed. The example first tests whether the B parameter has been passed and, if necessary, passes the same parameter to the internal B_Local variable. To continue a program without an error message when an error occurs, use the following format: Use the On Error Resume Next command with caution as its effect is global. If on the other hand, the example encounters another field, then it displays the information unknown. In general, only parts of the interfaces are discussed. The third section moves beyond work with texts. Some DOS-specific properties are no longer used in functions that expect file properties as parameters (for example, to differentiate from concealed files and system files). en For example, LibreOffice Basic only allows special characters in markers when using Option Compatible, since they can cause problems in international projects. The third section deals with presentations. This service provides the following properties: When you format sheets, you can define whether page elements are visible. LibreOffice Basic provides a range of tools for simplifying error handling. LibreOffice provides hundreds of services. Context-dependent objects are usually created by means of an object method, on which the object depends. Here are a few examples of Variant variables: The variables declared in the previous example can even be used for different variable types in the same program. Programmers of other languages such as Java, C++, or Delphi should also find it easy to familiarize themselves with LibreOffice Basic. These in turn contain the various cells. The expression MB_YESNOCANCEL + MB_DEFBUTTON3 is harder to write, but easier to understand. When first requested, a string containing the path of the directories to be searched must be assigned to Dir as its first parameter. LibreOffice also supports complex polygonal shapes through the com.sun.star.drawing.PolyPolygonShape service. In addition to the FillTransparence property, the com.sun.star.drawing.FillProperties service also provides the FillTransparenceGradient property. In addition to direct formatting, you can also format text using templates. A spreadsheet consists of a two-dimensional list containing cells. Finally, when calling up a text file, the eof instruction is used to check whether the end of the file has been reached: The following example shows how a text file can be read: The individual lines are retrieved in a Do While loop, saved in the Msg variable, and displayed at the end in a message box. Here are the central methods that the com.sun.star.text.TextCursor service provides for navigation: The text is divided into sentences on the basis of sentence symbols. All drawing objects that can have a border line support the com.sun.star.drawing.LineStyle service. The basic object must provide the XEnumerationAccess interface, which contains only a createEnumeration method. It is called a ReplaceDescriptor and supports the com.sun.star.util.ReplaceDescriptor service. The text frame is created using the createInstance method of the document object. These are presented in detail in the #Introduction to the LibreOffice API. The waiting period is specified in milliseconds. You can access slides in the same way as a standard drawing is accessed through the DrawPages list of the document object. More information about working with these buttons is discussed in #Control Elements in Detail. Documents are opened, imported and created using the method StarDesktop.loadComponentFromURL(URL, Frame, SearchFlags, FileProperties) The first parameter of loadComponentFromURL specifies the URL of the associated file. A text field can contain one or more lines and can be edited or blocked for user entries. In all other instances (that is, if A is greater than or equal to 3), B is assigned the value 2. The example shows a dialog that contains a label and a list box. VBA: Different terminology for spreadsheets and their content is used in VBA and LibreOffice Basic. It can access databases created by many database programs, including Microsoft Access, MySQL, Oracle, and PostgreSQL. The formatting properties can be found in each object (Paragraph, TextCursor, and so on) and can be applied directly. The Statement object used to create the ResultSet provides some properties which allow the functions of the ResultSet to be influenced: The values defined in com.sun.star.sdbc.ResultSetConcurrency are: The com.sun.star.sdbc.ResultSetType group of constants provides the following specifications: Note: With the help of this controller object and the model of the control element, it then uses the GetControl method to determine the view (CtlView variable) of the control element form. Here is an list of the most important properties of the table object: A table consists of a list containing rows. You can also use plus (+) or minus (-) signs as prefixes for decimal numbers (again with or without spaces). Common pieces of reusable Python or UNO features must be stored in My macros within (User Profile)/Scripts/python/pythonpath. The example creates a TextTables list containing all tables of a text that are traversed in a loop. Download PDF. Therefore, before copying the content from B to A, B has to be converted into A's internal format. Here is an overview of the most important formatting properties and the points at which they are explained: The format properties are by no means restricted to the applications in which these are explained, but instead can be used universally. The following example shows how all element names of a spreadsheet can thereby be determined and displayed in a loop: The hasByName method of the XNameAccess interface reveals whether a subordinate object with a particular name exists within the basic object. The location of individual cells in a cell range can be determined using the getCellByPosition method, where the coordinates of the top left cell in the cell range is (0, 0). The Chart object provides the property Diagram which forms the coordinate system with axes and grids, where the data finally is displayed: Different services are supported depending on the chart type (see #Chart Types). A simple way is to declare it as a Private or Public variable common to the main dialog routine and the event routine. The following example therefore displays a message that informs the user whether the Spreadsheet object contains a page of the name Sheet1. An ma unit is defined as being one eighth of the average height of a character from the system font defined in the operating system and one quarter of its width. VBA: When requested in LibreOffice Basic, the Dir function, using the parameter 16, only returns the sub-directories of a folder. as the decimal point. This is probably not what you want. The As keyword syntax, and the fact that a comma is not used, goes back to the roots of the Basic language. Unicode increases the length of a character to four bytes and combines different character sets to create a standard to depict as many of the world's languages as possible. However, these speed considerations no longer apply, reducing the need for single variables. By default, the parameters are passed by reference. To pass parameters as values, use the ByVal keyword. The Step-value of 0 is a special case. Both the X and Y-axes have a gray grid for visual orientation. For a multi-dimensional array you need to specify the position (1 to n) of the index you want to know the permitted lower and upper values: In some cases, especially when dealing with the API, you need to declare an empty array. This is not the case for new documents. The decimal point is fixed and is followed by four decimal places. The Format function formats numbers as a string. VBA: The VBA option for issuing list entries with a numerical additional value (ItemData) does not exist in LibreOffice Basic. LibreOffice Basic then interprets the following line as a regular instruction again. The following example moves the B2:C3 range so that the range starts at position A6: In addition to the CellRangeAdress structure, the moveRange method expects a com.sun.star.table.CellAddress structure to define the origin of the move's target region. LibreOffice Basic supports Modules and Libraries. Before the corresponding call can be made, the polygon must be inserted into the document. In particular, if such a request is made by pressing the right mouse button on the control, the event will be fired twice: once for the popup menu request, and once for the real mouse event. Data sources provide a range of properties, which in turn provide general information about the origin of the data and information about access methods. These may be outside the flow of text and can be positioned anywhere on the page. The following subroutine, adapted from the Template Changer extension, will re-enable the update feature for all document types. A similarity search is used so that not only the word turnover, but also the plural form "turnovers" and declinations such as "turnover's" are found. Example declarations for single variables: Double variables can store any positive or negative floating point numbers between 1.79769313486232 x 10308 and 4.94065645841247 x 10-324. If you close a dialog by clicking the OK button, the Execute method returns a return value of 1, otherwise a value of 0 is returned. The central properties are: The following example creates a text frame using the properties described previously: The example creates a TextCursor as the insertion mark for the text frame. By means of the (non-genuine) properties LeftText, CenterText, and RightText, this service provides three text elements for the headers and footers of LibreOffice Calc. If you want to find other matches for the string, the function also provides the opportunity to specify an optional start position from which LibreOffice Basic begins the search. com.sun.star.awt.UnoControlTimeField, A numeric field makes it possible to enter, display and edit formatted numeric values. In its simplest form, the print call is: As in the case of the loadComponentFromURL method, the Dummy parameter is a PropertyValue data field through which LibreOffice can specify several options for printing. Any modifications made to the data within the spreadsheet will also be reflected in the assigned chart. The following call can therefore be used to provide a file with read-only status: The date and time of the last amendment to a file are provided by the FileDateTime function. You specify the qualifiers in the With statement. The return value of a function can be any type. In LibreOffice, these properties are defined using a page style which in turn is linked to the associated document. The Basic interpreter first calculates the result of the addition process and then converts this into a string, which, as its result, produces the string 2. If assignment is successful, the function returns True. If this is the case, the Control.Name property then checks whether the name of the control element is MyListBox. The com.sun.star.text.Paragraph service grants access to the content of a paragraph. The following example is an algorithm that uses two loops to sort a list by names. The error sources noted for implicit type conversions can only be avoided by careful programming; for example, by not using the variant data type. The following example shows how the Dir function can be used to request all files located in one directory. Note: Information about creating, opening, and saving drawings can be found in #Working With Documents. A number of UNO objects support the supportsService method, with which you can establish whether an object supports a particular service. In some situations, it is not the actual text of a document, but rather its structure that needs modifying. To open a file so that it can be written as a text file, the Open call is: Filename is a string containing the name of the file. To do this, all option buttons of a group must contain the same name. This is needed to specify the paper size. As of LibreOffice Version 3.0, unlike variables, there is no way to make the definition accessible outside of the module. If you want to use such a name, you must tell Basic where to look. LibreOffice automatically ensures that the relevant data is retrieved from the database, and that any changes made are written back to the database. For example: The DoLoop is not linked to a fixed number of passes. VBA: Unlike VBA, you cannot insert option buttons in a group of control elements in LibreOffice Basic. The figure above shows the LibreOffice Basic development environment with a dialog window that contains two list boxes.

Chimp Attack Caught On Camera, Double Pivot Damper Handle, Lala Milan Gender, Articles L

0 답글

libreoffice basic programming guide pdf

Want to join the discussion?
Feel free to contribute!

libreoffice basic programming guide pdf