Finally, the removeByName call removes the object behind OldStyle from ParagraphStyles. OpenOffice.org BASIC Programming Guide 2 OpenOffice. An option button control element provides two properties: You can also use the following properties from the model of the option buttons: To combine several option buttons in a group, you must position them one after another in the activation sequence without any gaps (Model.TabIndex property, described as Order in the dialog editor). The following example lists the names of data source queries can be established in a message box. its spell checker, forms designer, and charting tools). Note: To split a string across two lines of code, add an ampersand sign (the concatenation operator) and the underscore continuation character at the end of the first line: To include a quotation mark (") in a string, enter it twice at the relevant point: LibreOffice Basic supports five basic types for processing numbers: Integer variables can store any whole number between -32768 and 32767. To determine a special control element, all drawing elements of the drawing level must be searched through. To convert local file names into a URL, LibreOffice provides the ConvertToUrl function. org BASIC Programming Guide This guide provides an introduction to programming with OpenOffice.org Basic. The text field is then inserted in the document using the insertTextContent method. In this guide, a table-based document or spreadsheet document is the entire document, whereas a spreadsheet (or sheet for short) is a sheet (table) in the document. By default, the parameters are passed by reference. Note: Logical operators allow you to do operations on elements according to the rules of Boolean algebra. Some UNO services in turn support other services so that, through one object, you are provided with a whole range of services. Since the points of a polygon are defined as absolute values, you do not need to specify the size or the start position of a polygon. Note: Here are a few examples: The following example shows how all empty lines in a text document can be removed with the help of the regular expression ^$: So far, this chapter has only dealt with text paragraphs and their portions. A . 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. When it is used with 4 arguments, to replace a sub-string in a string, Mid is an instruction, not a function: it does not return any value! You cannot modify the objects once they are in the group. First it splits "Source" dividing it at all "Search", and joins the parts back with "NewPart". What is written here also applies to Impress documents. To get the most out of this book, you should be familiar with other programming languages. Once the message box has been confirmed, it replaces the content of the window with the test2.odt file. 257x267px This distinction is not made in LibreOffice Basic, because charts in LibreOffice Calc are always created as embedded objects of a table page. Whereas the Document.Tables.Add method takes on the task of creating and setting the table in VBA, this is created in LibreOffice Basic in accordance with the previous example using createInstance, initialized, and inserted in the document through insertTextContent. Numbers are left-aligned in the cell instead of right-aligned. The StarDesktop object replaces the Application object of StarOffice 5 which previously applied as a root object. The endDialog method of the dialog is an improvement of endExecute. The LibreOffice API provides you with a whole range of objects with which you can create, open and modify Office documents. 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. Note: LibreOffice Basic returns the name of the first directory entry found. This event is also used for notifying requests for a popup context menu on the control. This chapter provides an overview of the key elements and constructs of the LibreOffice Basic language, as well as the framework in which applications and libraries are oriented to LibreOffice Basic. The right and left-hand edges of the line extend to their points of intersect with each other (LineJoint = MITER) to form a right-angle. In LibreOffice Basic, use the keyword Const to declare a constant. A complete list of all character properties can be found in the LibreOffice API reference. Note: 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. The example first checks if the error number corresponds to the expected number (as stored in the imaginary ExpectedErrorNo constant) and then handles the error accordingly. Essential parameters must be enclosed in parentheses after the function or procedure names. The color for the rear wall of the chart is set to white. Note: LibreOffice, the best free and open source office suite. This function is not available in dialogs. The properties are: Note: The Val function is different from the Csng, Cdbl and Cstr methods. LibreOffice Basic is a fully-developed procedural programming language and no longer requires rudimentary control structures, such as GoTo and GoSub. Ability to open, edit, and save Microsoft Excel spreadsheets. If UserInput does not contain a valid number, ValidInput is assigned the value 0 and an error message is returned. An object which supports the com.sun.star.sdb.QueryDefinition service is concealed behind a query. 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. It converts a string into a number; however it always expects a period to be used as the decimal point symbol. MsgBox displays a basic information box, which can have one or more buttons. The following example uses the hasByName method to check if a page called MyPage exists. Here are a few example calls for the named functions: LibreOffice Basic provides the InStr function for searching for a partial string within another string: The StringToFind parameter specifies the string to be searched for within MyString. Note: You can define modules to be global or part of a document. 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. There is no type declaration symbol for Boolean variables. Methods can be understood as functions that relate directly to an object and through which this object is called. If the calls to SetModuleB and ShowVarB are independent, e.g. "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. The example first creates a list containing all rows using a Table.getRows call. Issue 31001 Issue 54049 Issue 91121 Issue 107277 are still not corrected. In accordance with UNO philosophy, an Obj is described as a reference to an object which supports the com.sun.star.frame.Desktop service. 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 type declaration symbol for date variables. The Map AppFont (ma) replaces the Twips unit to achieve better platform independence. For charts in which the values of the various rows of data deviate significantly from one another, LibreOffice provides a second X and Y-axis for second scaling operations. In so doing, the name of the proper com.sun.star.text.TextFrame service should be specified. chapter #Programming Dialogs and Dialog Controls shows more examples in Basic. Warning: These in turn contain the various cells. In some situations, it is not the actual text of a document, but rather its structure that needs modifying. The following example creates and inserts a rectangle in a drawing document: The Point and Size structures with the point of origin (left hand corner) and the size of the drawing object are then initialized. Changes made to the variables are retained when the procedure or function is exited: In this example, the value A that is defined in the Test function is passed as a parameter to the ChangeValue function. The code used in the example then creates a list containing all charts of the first spreadsheet (Charts line = Doc.Sheets(0).Charts). These are: The code for saving a document can be extended by these options so that the document is only saved if the object has actually been modified and the file name is only queried if it is actually needed: The example first checks whether the relevant document has been modified since it was last saved. The com.sun.star.table.CellProperties service provides the following properties for defining background colors and shadows: The com.sun.star.table.ShadowFormat structure and the detailed specifications for cell shadows have the following structure: The following example writes the number 1000 to the cell B2, changes the background color to red using the CellBackColor property, and then creates a light gray shadow for the cell that is moved 1 mm to the left and down. The structure is further complicated by tables. The example creates a TextTables list containing all tables of a text that are traversed in a loop. In other words, formatting using templates is assigned a lower priority than direct formatting in a text. The dispose method at the end of the code releases the resources used by the dialog once the program ends. The LibreOffice API has been structured so that as many of its parts as possible can be used universally for different tasks. LibreOffice Basic recognizes but ignores this keyword, because this is already the default procedure in LibreOffice Basic. In the following example, the loop is terminated during the fifth pass: The For EachNext loop variation in VBA is supported in LibreOffice Basic. This section describes four services and in each instance the sample program code uses a rectangle shape element that combines several types of formatting. 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. The Assign Action dialog lists all the available Events. It supports the createTextCursor interface for creating an associated TextCursor object. XIndexAccess provides the methods for accessing individual objects. The following call also specifies the True parameter for the document object when requesting the Save method. (When listing the service name of a text field, uppercase and lowercase characters should be used in LibreOffice Basic, as in the previous example.). The replaceByName line changes the object behind ChangingStyle into NewStyle. The loop is terminated as soon as the hasMoreElements method returns the False value, signaling that the end of the text has been reached. The hasByName, getByName and insertByName methods are obtained from the com.sun.star.container.XNameContainer interface as described in #Introduction to the API. This is not the case for new documents. When using the CompatibilityMode ( true ) function, LibreOffice Basic behaves like VBA and the Dir function, using parameter 16, returns sub-directories and standard files. All of these charts support the com.sun.star.chart.StackableDiagram service, which in turn provides the following properties: Line charts (com.sun.star.chart.LineDiagram) support two X-axes, two Y-axes and one Z-axis.