libreoffice basic programming guide pdf

The following call deletes the Filename file. The following rules apply to numerical characters in LibreOffice Basic: The simplest method is to work with whole numbers. The Rows and Columns objects of a sheet can access existing rows and columns as well as insert and delete them. While test functions exist for checking numbers, date details and arrays in LibreOffice Basic, a corresponding function for checking Boolean values does not exist. Issue 31001 Issue 54049 Issue 91121 Issue 107277 are still not corrected. The InputBox function queries simple strings from the user. The example code modifies the content in each of these paragraph portions using the String property of the string. In some situations, it is not the actual text of a document, but rather its structure that needs modifying. (For Writer documents only, you can use the Template Changer extension to set this feature again.). The wall is set to be blue. This is because the contents of cell A2 were entered as a string and not as a number. As already mentioned, the size and position of control elements can be determined using the associated shape object. The FileLen function determines the length of a file in bytes (as long integer value). In a similar way to the search window, the settings needed for a search can be set in the SearchDescriptor object. The LibreOffice API provides you with a whole range of objects with which you can create, open and modify Office documents. The form can be defined using two properties. These determine the procedure LibreOffice uses when saving a document. The most important of these events are: When you work with events, note that some events, such as the When initiating event, can be initiated each time you click the mouse on some control elements (for example, on radio buttons). A struct is an ordered collection of data fields, that can be manipulated as a single item. The variable can contain up to 15 numbers before the decimal point. Note: LibreOffice positions the control elements of a form at drawing object level. It only continues with the saving process if this is the case. The variable RangeAddress determines the assigned cell range whose data will be displayed within the chart. You can also benefit from the advantages of object-oriented programming since an interface in LibreOffice Basic enables you to use external object libraries. A LibreOffice Basic object can, however, support several services. The sources from which the drivers take their data is irrelevant to a SDBC user. The Goto ErrorHandler ensures that LibreOffice Basic exits the current program line and then executes the ErrorHandler: code. You can move the data from one list to the other using the buttons between the two list boxes. There are passed through in turn in a loop. The following focus events are available: The Event objects for the focus events are structured as follows: In addition to the preceding events, which are supported by all control elements, there are also some control element-specific events that are only defined for certain control elements. The CompatibilityMode statement and function provide greater compatibility with VBA, by changing the operation of certain functions. In dialogs, the distinction between data and depiction is not always as clear as in other API areas of LibreOffice. To make your code easier to read, you should assign meaningful names to these procedures. You can open a dialog with the following code: CreateUnoDialog creates an object called Dlg that references the associated dialog. In error handling, it is useful to have a description of the error and to know where and why the error occurred: shows how the error information can be displayed in a message window. Note: 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. In LibreOffice, the fields are administered using an object-oriented concept. In addition to the drawing functions that are provided by the Presentation property, the presentation document has a presentation object that provides access to the main properties and control mechanisms for presentations. By using ma units, LibreOffice ensures that a dialog looks the same on different systems under different system settings. com.sun.star.awt.UnoControlDateField, A time field makes it possible to enter, display, and edit time values. The com.sun.star.style.CharacterProperties service does not provide any interfaces, but instead offers a range of properties through which character properties can be defined and called. This uses the query window to check the SQL commands typed and corrects simple syntax errors, such as those associated with uppercase and lowercase characters. About OpenOffice.org Basic and allows these to be created, saved, modified, and printed. The assignments. Graphic objects support two of the general formatting properties: Additional properties that are supported by graphic objects are: The following example shows how to insert a page into a graphics object. This includes the distance of the paragraph from the edge of the page as well as line spacing. In some instances, the date cannot be converted: In the example shown, the assignment of the test string to a date variable makes no sense, so the Basic interpreter reports an error. The removeByIndex method deletes the sixth column (index 5). Finally the code sets the Label property of the control element to the New Label value. Since the drivers are based on UNO components, other drivers can be developed and therefore open up new data sources. The areas can be stacked (com.sun.star.chart.StackableDiagram). The 0 character within the template ensures that a number is always placed at the corresponding point. If you are running from within the Basic IDE, debugging or exploring, then StarDesktop returns the Basic IDE itself. The complete name in the named example would be: In addition to the module and service terms, UNO introduces the term 'interface'. Conversely, the CStr methods use the currently selected country-specific settings when formatting numbers, dates and time details. Upon closer inspection, the following code sequence. Text tables are available in LibreOffice through the TextTables list of the document object. A Const definition in the module header is available to the code in that module. VBA: While the type of a field in VBA is specified by a parameter of the Document.Fields.Add method, the name of the service that is responsible for the field type in question defines it in LibreOffice Basic. If you start the macro from the IDE, ThisComponent will still find and return your document. This event is initiated by either a key-press or a mouse button. To create a hatch fill, the FillStyle property must be set to HATCH. Mathematical operators can be applied to all numbers types, whereas the + operator can also be used to concatenate strings. 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. Depending on the system and configuration, various types of data are saved here. Here are the central methods of the com.sun.star.table.XtableRows interface: Whereas the getByIndex and getCount methods are available in all tables, the insertByIndex and removeByIndex methods can only be used in tables that do not contain merged cells. If you set this value to zero in a dialog, all the control elements are visible regardless of their Step value. This is an instance of the example function described in #Search and Replace. The view of the control element can then be determined with the assistance of the model and using the document controller. 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. Note: The expression, is interpreted as 1.43 minus 2, which corresponds to the value -0.57. This code inserts the test.jpg graphic and adapts its appearance using the Adjust properties. As a parameter, this takes the name of the property and returns a constant that provides information about the origin of the formatting. To determine a special control element, all drawing elements of the drawing level must be searched through. Note: The Form Functions Toolbar is used for editing forms. can define the digits after the decimal point in an expression: In the same way, zeros can be added in front of a number to achieve the desired length: A , represents the character that the operating system uses for a thousands separator, and the # stands for a digit or place that is only displayed if it is required by the input string. Note: A Boolean value is saved internally as a two-byte integer value, where 0 corresponds to the False and any other value to True. You do not need to use another program to create PDFs, unless your printing service requires you to do so. The following properties are provided for 3D charts at the Diagram object: The following example creates a 3D area chart. When variable I equals 10, the loop stops. An example of the use of XNameAccess is provided by the sheets object of a spreadsheet. The Select Case statement evaluates the expression, which is TRUE or FALSE, and then compares that value to Var. The procedure saves the individual file names in the AllFiles variable and then displays this in a message box. The createTextCursorByRange call then creates a Cursor, which is positioned at the anchor position of the bookmark. The following subroutine, adapted from the Template Changer extension, will re-enable the update feature for all document types. As an alternative, a validity range with start and end values can be specified for the data field declaration. Note: To avoid this problem, the DateSerial function should be used to assign a fixed value to a date variable: The function parameter must be in the sequence: year, month, day. Version 2.0 of Unicode is now supported by many programs including LibreOffice and LibreOffice Basic. To define the cell range that you want to insert, use the com.sun.star.table.CellRangeAddress structure. For more information, see the LibreOffice API reference. This reflects the content of a table or the result of a SQL-SELECT command. The following call creates a copy of the Source file under the name of Destination: With the help of the following function you can rename the OldName file with NewName. The code used in the example then creates a list containing all charts of the first spreadsheet (Charts line = Doc.Sheets(0).Charts). A problem may arise if you click on No: the styles will not be updated, and the automatic-update feature will be turned off. The API does not provide a method to change the position of a page inside a drawing document. This is useful, for example, if the contents of different databases are displayed within one document, or if a 1:n database relationship is displayed within a form. To assign an explicit string to a string variable, enclose the string in quotation marks ("). 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. Finally, the removeByName call removes the object behind OldStyle from ParagraphStyles. This includes declaring multi-dimensional data fields and specifying explicit start and end values. However, whether the corresponding settings are based on template or direct formatting in the text is still unclear. 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. As with all TextContent objects, a distinction is also made with text frames between the actual creation and insertion in the document. The function ensures that the variable is actually assigned the correct value regardless of the country-specific settings. As can be seen in the example from the previous section, LibreOffice provides a getString method for accessing table contents. LibreOffice Writer supports the following types of styles: LibreOffice Calc supports the following types of styles: LibreOffice Impress supports the following types of styles: In LibreOffice terminology, the different types of styles are called StyleFamilies in accordance with the com.sun.star.style.StyleFamily service on which they are based. StarOffice 5: StarDesktop.loadComponentFromURL supersedes the Documents.Add and Documents.Open methods from the old LibreOffice API. Throughout this document, the LibreOffice installation directory is represented in syntax as install-dir. Note: If there is not enough space, or if this results in long lines, then several lines can be linked together by adding underscores _. If you click on Yes, the new or changed styles will be copied into the document. The FileProperties array has two elements, one for each option used. Text fields are TextContent objects because they provide additional logic extending beyond pure text. The second section concentrates on how to edit spreadsheets efficiently by focusing on cell areas and the options for searching and replacing cell contents. Note: Internally, LibreOffice Basic saves the associated Unicode value for every character. Before you can create the dialog, you must ensure that the library it uses (in this example, the Standard library) is loaded. For example, you can define an array to contain all the words in a text that begin with the letter A. Constants have the same scope as variables (see #Scope_of_Variables Scope and Life Span of Variables), but the syntax is slightly different. Although this provides considerable flexibility, it is best to restrict a variable to one variable type. To do this, all option buttons of a group must contain the same name. 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 user can therefore, for example, change the font type of all level one headers by means of a central modification in the document. Establishing whether a section of a document has been directly or indirectly formatted is not easy. It converts a string into a number; however it always expects a period to be used as the decimal point symbol. The DrawPages container of a drawing document is also used to create and delete individual pages. The following properties of an option button are available through its model object: The mechanism for grouping option buttons distinguishes between the control elements for dialogs and forms. In the preceding example, if we replace the ChangeValue function then the superordinate variable A remains unaffected by this change. In this example, the graphics are depicted as 40 percent transparent with no other color conversions do not take place (GraphicColorMode = STANDARD). The basic functionality for the individual document objects is provided by the com.sun.star.document.OfficeDocument service. LibreOffice notes the SQL commands of queries so that they are available at all times. The preceding Document object could, for example, provide a Save method, which can be called as follows: Methods, just like functions, may contain parameters and return values. In addition to an object for individual cells (com.sun.star.table.Cell service), LibreOffice also provides objects that represent cell ranges. Some interfaces of LibreOffice can be found in many parts of the LibreOffice API. LibreOffice Basic dialogs consist of a dialog window that can contain text fields, list boxes, radio buttons, and other control elements. The individual data sources are based on the com.sun.star.sdb.DataSource service and can be determined from the database context using the getByName method: The example creates a DataSource object for a data source called Customers. The previous example may change the text as requested, but it may sometimes also destroy the formatting. StarOffice 5: The name of the StarDesktop object dates back to StarOffice 5, in which all document windows were embedded in one common application called StarDesktop. VBA: The ResultSet object from SDBC is comparable with the Recordset object from DAO and ADO, since this also provides iterative access to a database. 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. Styles deleted from the template are not removed from documents. 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. 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. As in the old API from LibreOffice, searching and replacing text in the new API is also performed using the document object. By means of a storeAsURL method option, the user can save the original XML files directly. The following path references the test.odt file in the doc directory on the C: drive: file:///C:/doc/test.odt The objects are accessed as follows in text documents: The GetByIndex method returns the form with the index number 0. If the text of the paragraph is now changed using the paragraph's String property, then LibreOffice first deletes the old paragraph portions and inserts a new paragraph portion. Programmers of other languages such as Java, C++, or Delphi should also find it easy to familiarize themselves with LibreOffice Basic. Then the new page is renamed. Example declarations of double variables: Currency variables differ from the other variable types by the way they handle values. The endDialog method of the dialog is an improvement of endExecute. getByIndex provides an object with a particular index. The area highlighted by the TextCursor therefore begins after the seventh character in the text and ends after the tenth character. placeholders in both VBA and LibreOffice Basic. Numbers can be inserted and called up with the Value property, text with the String property, and formulas with the Formula property. A currency variable can store any value between -922337203685477.5808 and +922337203685477.5807 and takes up to eight bytes of memory. Let us first take the properties of the table itself. LibreOffice also supports complex polygonal shapes through the com.sun.star.drawing.PolyPolygonShape service. 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). This distinction is not made in LibreOffice Basic, because charts in LibreOffice Calc are always created as embedded objects of a table page. Charts are not treated as independent documents in LibreOffice, but as objects that are embedded in an existing document.

How To Load Staples In A Swingline Automatic Stapler, Articles L

Tags: No tags

libreoffice basic programming guide pdfAdd a Comment