libreoffice basic programming guide pdf

LibreOffice recognizes five different axes that can be used in a chart. In addition to direct formatting, you can also format text using templates. Subs and functions are always contained in modules. These include the previously described com.sun.star.text.Paragraph services for paragraphs as well as the com.sun.star.text.TextPortion services for paragraph portions. To assign a macro to an event: The occurrence of a particular event is not always enough for an appropriate response. The following example is an algorithm that uses two loops to sort a list by names. This is not, for example, possible with complex SQL commands with linked columns or accumulated values. getByIndex provides an object with a particular index. The parameter provides the option of adding additional buttons, defining the pre-assigned button, and adding an information symbol. Warning: The example defines a procedure called Test that contains code that can be accessed from any point in the program. In addition to the program code to be executed, an LibreOffice Basic program can also contain comments that explain the individual parts of the program and provide important information that can be helpful at a later point. Care should be taken when you use the On Error Resume Next command as this dismisses all open error messages. If this procedure was created in LibreOffice Basic, you can assign it to an event required using the property window of the dialog editor. In addition to simple variables (scalars), LibreOffice Basic also supports arrays (data fields). The following expressions assign the various Unicode values to the code variable: ensures that the MyString string is initialized with the value of the number 13, which stands for a hard line break. You can apply all the named properties to individual cells and to cell ranges. Since LibreOffice is a platform-independent application, it uses URL notation (which is independent of any operating system), as defined in the Internet Standard RFC 1738 for file names. This includes the way in which file names are structured for LibreOffice documents, as well as the format in which files are saved. Such CellRange objects are created using the getCellRangeByName call of the spreadsheet object: A colon (:) is used to specify a cell range in a spreadsheet document. You can use these properties to trigger an event within an event handler. If a dialog contains an OK or a Cancel button, the dialog is automatically closed when you click one of these buttons. In LibreOffice, various types of charts can be displayed in a stacked form. Internally, LibreOffice Basic saves the associated Unicode value for every character. If the user presses several keys to output a single character (for example, to add an accent to a character), then LibreOffice Basic only creates one event. In very rare cases, before calling up some property, use the IsEmpty function to check whether it is actually available. The com.sun.star.awt.UnoControlEdit service forms the basis for text fields. A chart may contain its own data or may display data from the container document. Jumping directly to a general program procedure from a macro can result in unclear code. The LibreOffice Basic programming language can be divided into four components: Note: The following list describes the most important properties: Formatting information that does not refer to individual characters, but to the entire paragraph is considered to be a paragraph property. OpenOffice.org BASIC Programming Guide 2 OpenOffice. In the following example, the loop is terminated during the fifth pass: The For EachNext loop variation in VBA is supported in LibreOffice Basic. Note: The following example shows how to create a chart assigned to some cell ranges within a spreadsheet document: Although the code used in the example may appear to be complex, the central processes are limited to three lines. Text fields are TextContent objects because they provide additional logic extending beyond pure text. The following example creates a line chart. The start index of a data field usually begins with the value 0. These services are appropriate for applications in which the content of a text is to be edited in one pass through a loop. A database context object that is created using the createUnoService function serves as the starting point for accessing a data source. In LibreOffice, these properties are defined using a page style which in turn is linked to the associated document. Instead use the LibreOffice Basic MouseUp event for the click event and imitate the Doubleclick event by changing the application logic. Since these function areas are available in all types of documents, they are explained first in this chapter. Note: The False parameter in the previous function call specifies whether the area passed over with the cursor movement is highlighted. The model object of a checkbox form provides the following properties: The model objects of text field forms offer the following properties: The model object of the list box forms provides the following properties: Note: These may be outside the flow of text and can be positioned anywhere on the page. Every UNO object knows what properties, methods and interfaces it already contains. Note: To do this, all option buttons of a group must contain the same name. This basically covers the loadComponentFromURL method, which is responsible for creating, importing, and opening documents. Line charts provide the following properties: Area charts (com.sun.star.chart.AreaDiagram service) support two X-axes, two Y-axes and one Z-axis. The type declaration symbol for a currency variable is @. LibreOffice recognizes four main types of formatting for a fill area. If the width of an individual cell is changed, the width of the column that contains the cell is not changed. These variables are available to all the modules in their library: The value of variable A is not changed by the Test function, but is increased by one in the Flip function and decreased by one in the Flop function. It calls a text document, which contains a StyleFamilies object and uses this to in turn make the paragraph templates (ParagraphStyles) of the document available. Sunday is considered the first day of the week. This depends on the rotation of the chart. The procedure for defining page formats differs from other forms of formatting. You can also use the com.sun.star.drawing.Text service to position and format text in drawing object. For example, to create Yes, No and Cancel buttons (value 3) where Cancel is the default (value 512), the parameter value is 3 + 512 = 515. The formatting properties can be found in each object (Paragraph, TextCursor, and so on) and can be applied directly. The interfaces to various LibreOffice applications, which allow for direct access to Office documents. The argument of the method is the position, counted from 0, of the existing page after which the new page will be inserted. Two chart walls usually exist for 3D charts: one behind the plotted data and one as the left-hand or right-hand demarcation. The user interface provides a corresponding option for creating data sources in the Extras menu. One of these is used to query the value of the property and the other is issued to set it (get and set methods). The program now checks whether the ResultSet actually exists and traverses the data records using a loop. Anyone who has previously worked with other Basic languages in particular with Visual Basic or Visual Basic for Applications (VBA) from Microsoft will quickly become accustomed to LibreOffice Basic. The parameters are structured in the same way as the corresponding functions in XNameContainer. As with the loadComponentFromURL method, some options can also be specified in the form of a PropertyValue data field using the storeAsURL method. This is because the contents of cell A2 were entered as a string and not as a number. This method deletes the range that is defined in the CellRangeAddress structure from the sheet. To do this, you first create a standard LibreOffice Writer or LibreOffice Calc form and then link the fields to a database. This is needed to specify the paper size. Download PDF. Once the method has been completed, Save saves a return value in the Ok variable. Another mechanism for changing the text of headers and footers is available for text documents (LibreOffice Writer) because these consist of a single block of text. If you are running from within the Basic IDE, debugging or exploring, then StarDesktop returns the Basic IDE itself. = 1. The Step-value of 0 is a special case. In addition to inserting text fields, searching a document for the fields can also be an important task. In the following example, variable I is the loop counter, with an initial value of 1. The return value is assigned using simple assignment. It accesses the array of models using the GetGroupByName method (rather than the GetByName method to determine simple models). Double variables are suitable for precise calculations. The found expressions differ by up to two letters from the search expression: Note: Functions and procedures can only be called up if all the necessary parameters are passed during the call. The LibreOffice API (Application Programming Interface): Permits access to LibreOffice documents and allows these to be created, saved, modified, and printed. A spreadsheet consists of a two-dimensional list containing cells. The previous section has already discussed a whole range of options for editing text documents, focusing on the com.sun.star.text.TextPortion and com.sun.star.text.Paragraph services, which grant access to paragraph portions as well as paragraphs. There is no direct counterpart in LibreOffice Basic for the Characters, Sentences and Words lists provided in VBA. Here are a few examples of correct and incorrect markers: Enclosing a variable name in square brackets allows names that might otherwise be disallowed; for example, spaces. For a more detailed picture, see the API reference. The example first creates a text field which supports the com.sun.star.text.textfield.PageNumber service. The descriptor objects for searching and replacing in spreadsheet documents are not created directly through the document object, but rather through the Sheets list. This function creates directories and sub-directories. LibreOffice Basic saves strings as string variables in Unicode. LibreOffice Basic dialogs consist of a dialog window that can contain text fields, list boxes, radio buttons, and other control elements. Numbers are left-aligned in the cell instead of right-aligned. This is called indirect formatting. The objective of developing this interface was to provide access to as many different data sources as possible. The following example uses the String property to display the first words of a sentence in a message box: The first word of each sentence can be modified in the same way using the String property: If the TextCursor contains a highlighted area, an assignment to the String property replaces this with the new text. The Format Cells dialog in LibreOffice Calc provides an overview of the different formatting options for cells. VBA: The CellProperties object in the LibreOffice API is comparable with the Interior object from VBA which also defines cell-specific properties. In LibreOffice Basic, use the keyword Const to declare a constant. . Note that this name must not begin with an underscore. LibreOffice provides several ways of optimizing ResultSets and thereby controlling the speed of access. The StarDesktop object replaces the Application object of StarOffice 5 which previously applied as a root object. In addition to the standard properties, the following database-specific properties must also be set in the form: The com.sun.star.sdb.CommandType enumeration covers the following values: The database fields are assigned to the individual control elements through this property: Another control element is provided for work with databases, the table control element. The ISO standard introduces new character sets (code pages) so that more languages can be correctly displayed. The example shows a loop that runs through all sheet elements one after another and saves a reference to each in the Sheet object variable. The example first creates a document object for the text that has just been opened. The text fields found are checked for the service supported using the supportsService method. They can, however, only be used in tables that do not contain merged table cells. You will find an overview of the character and paragraph properties available in LibreOffice in the following two sections. com.sun.star.chart.ChartTitle contains not only the listed formatting properties, but also two other properties: The legend (com.sun.star.chart.ChartLegend) contains the following additional property: The following example creates a chart with a title "Main Title String", a subtitle "Subtitle String" and a legend. If you start the macro from the IDE, ThisComponent will still find and return your document. XML-based files can be opened and edited with other programs. The associated com.sun.star.form.FormButtonType group of constants provides the following values: The OK and Cancel button types provided in dialogs are not supported in forms. This includes declaring multi-dimensional data fields and specifying explicit start and end values. Styles deleted from the template are not removed from documents. From a routine called by an event of a control, e.g. The following example changes the dimension of the initial array so that it can record 11 or 21 values: When you reset the dimensions of an array, you can use any of the options outlined in the previous sections. The scope of application for LibreOffice Basic begins where the standard functions of LibreOffice end. It contains the following properties: The following example uses the KeyCode property to establish if the Enter key, the Tab key, or one of the other control keys has been pressed. The com.sun.star.text.Paragraph service grants access to the content of a paragraph. The values are interchanged as pairs several times until they are finally sorted in ascending order. The com.sun.star.text.TextTableRow service provides the following properties: Columns are accessed in the same way as rows, using the getByIndex, getCount, insertByIndex, and removeByIndex methods on the Column object, which is reached through getColumns. To make your code easier to read, you should assign meaningful names to these procedures. A LibreOffice Basic object can, however, support several services. If you use the CompatibilityMode ( true ) function, LibreOffice Basic will behave like VBA. Buy a printed copy. This type of assignment, however, can cause errors, date and time values are defined and displayed differently in different countries. StarOffice 5: The Value, String, and Formula properties supersede the old PutCell method of StarOffice 5 for setting the values of a table cell. Event-Driven Macros This section describes how to assign Basic programs to program events. To change the search so that InStr is case sensitive, add the parameter 0, as shown in the following example: Using the previous functions for editing strings, programmers can search for and replace one string in another string: The function searches through the transferred Search string in a loop by means of InStr in the original term Source. The Asc and Chr functions allow the Unicode value belonging to a character to be established and/or the corresponding character to be found for a Unicode value. However, this may have fatal consequences. Line objects support all the general formatting services with the exception of areas. The Format function formats numbers as a string.

Zingzillas Game, Articles L

libreoffice basic programming guide pdf