In other words, code (like the above examples) that works in a particular document type should also work for the associated template type. The following responses, which are defined in the com.sun.star.beans.PropertyState enumeration, are possible: com.sun.star.beans.PropertyState.DIRECT_VALUE, the property is defined directly in the text (direct formatting), com.sun.star.beans.PropertyState.DEFAULT_VALUE, the property is defined by a template (indirect formatting), com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE. The createInstance method, which is defined in the XMultiServiceFactory interface, is used in particular in the document objects. The com.sun.star.frame.Desktop service, which is similar to the core service of LibreOffice. 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. The procedure for defining page formats differs from other forms of formatting. A is assigned the string 2. The function ensures that the variable is actually assigned the correct value regardless of the country-specific settings. Documents can also be created, opened and imported using this service. There are various ways of formatting text. Each of these documents may contain several spreadsheets. Text fields are TextContent objects because they provide additional logic extending beyond pure text. However, this is not sufficient for many problems. Bookmarks are created and inserted using the concept already described previously: The example creates a Cursor, which marks the insert position of the bookmark and then the actual bookmark object (Bookmark). Drawing objects include shapes (rectangles, circles, and so on), lines, and text objects. VBA: Unlike VBA, where you can only dimension dynamic arrays by using Dim MyArray(), LibreOffice Basic lets you change both static and dynamic arrays using ReDim. A LibreOffice Basic program can contain dozens, hundreds, or even thousands of markers, which are names for variables, constants, functions . This reflects the content of a table or the result of a SQL-SELECT command. It then creates an object that supports the com.sun.star.drawing.ShapeCollection service and uses the Add method to add the rectangle and the circle to this object. For more information, see the LibreOffice API reference. The Diagram object provides the following properties to access the grids: The grid object is based on the com.sun.star.chart.ChartGrid service, which in turn supports the line properties of the com.sun.star.drawing.LineStyle support service (refer to #Drawings and Presentations). The following is a list of several methods for editing highlighted areas using a TextCursor and which also support the com.sun.star.text.TextCursor service: The com.sun.star.text.TextCursor service supports all the character and paragraph properties that were presented at the start of this chapter. The hasByName, getByName and insertByName methods are obtained from the com.sun.star.container.XNameContainer interface as described in #Introduction to the API. Two chart walls usually exist for 3D charts: one behind the plotted data and one as the left-hand or right-hand demarcation. All drawing objects that can have a border line support the com.sun.star.drawing.LineStyle service. In addition to linking individual lines, in LibreOffice Basic you can use colons to divide one line into several sections, so that there is enough space for several expressions. InputBox receives three standard parameters: The Beep function causes the system to play a sound that can be used to warn the user of an incorrect action. All of the drawing objects that are described in the previous sections can also be rotated and sheared using the com.sun.star.drawing.RotationDescriptor service. It then converts a URL into a local file name and also displays this. 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 example first tests whether the B parameter has been passed and, if necessary, passes the same parameter to the internal B_Local variable. return the number of pages, words, or characters of a text. All objects that support the com.sun.star.text.Paragraph service also provide support for the paragraph properties in com.sun.star.style.ParagraphProperties. Before you can create the dialog, you must ensure that the library it uses (in this example, the Standard library) is loaded. No distinction is made between uppercase and lowercase characters. Queries are used to simplify working with databases because they can be opened with a simple mouse click and also provide users without any knowledge of SQL with the option of issuing SQL commands. In the first two examples, the code within the loop may not be executed at all ("do 0 times" logic). Regardless of this, the original methods are also available (in our example, getPosition and setPosition). 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. These include tables, drawings, text fields and directories. Character objects in UNO, for example, provide the getPosition and setPosition methods through which the associated key point can be called up and changed. Page properties are the formatting options that position document content on a page as well as visual elements that are repeated page after page. The following example searches through all tables of a text document and applies the right-align format to all cells with numerical values by means of the corresponding paragraph property. Finally, the removeByName call removes the object behind OldStyle from ParagraphStyles. The properties for formatting headers are: The properties for formatting footers are: The content of headers and footers in a spreadsheet is accessed through the following properties: If you do not need to distinguish between headers or footers for odd and even pages (the FooterIsShared property is False), then set the properties for headers and footers on odd pages. If the activation sequence is interrupted by another control element, then LibreOffice automatically starts with a new control element group that can be activated regardless of the first group of control elements. The following call returns some properties about a file. If it does, the method determines a corresponding object reference by using the getByName method and then saves the reference in a variable in Page. This is not the case for new documents. The formatting options that are available depend on the type of drawing object. Since other pages of the Developer's Guide . 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. This detail may be of interest in particular to Java- or C++ programmers, since in these languages, the interface is needed to request a method. The type declaration symbol for an integer variable is %. 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 store method of the com.sun.star.frame.XStorable interface is available for this purpose: This call functions provided that the document has already been assigned a memory space. This code uses the String-property of the rectangle to insert the text and the CharWeight and CharFontName properties from the com.sun.star.style.CharacterProperties service to format the text font. Calculations that use integer variables are very fast and are particularly useful for loop counters. You can write it more easily, this way: Notice that the With construct must be entirely outside of the Select construct. As Basic makes automatic type conversions, there is usually no problems using a constant in an expression. The active document object is accessed in LibreOffice through the StarDesktop.CurrentComponent property, or through ThisComponent. Finally, LibreOffice provides a mechanism for forms based on databases. In addition to inserting text fields, searching a document for the fields can also be an important task. If another error occurs, the system outputs a warning. VBA: In VBA, the Err.Clear method of the Err object resets the error status after an error occurs. The getByIndex method returns a row object, which supports the com.sun.star.text.TextTableRow service. The code in the following example moves an entry from the left to the right list box of a dialog. Before a text file is accessed, it must first be opened. These provide the option of defining a variable search expression with placeholders and special characters rather than a fixed value. The following example shows how a text file is opened, written, and closed: Text files are read in the same way that they are written. Whereas VBA uses the Document.Frames.Add method for this purpose, creation in LibreOffice Basic is performed using the previous procedure with the aid of a TextCursor as well as the createInstance method of the document object. For this reason, this algorithm is also known as a Bubble sort. One can be found in the createUnoService function mentioned at the start of this chapter. A Draw (or Impress) document is composed of pages, also called slides. Dialogs can, for example, display database information or guide users through a step-by-step process of creating a new document in the form of a Wizard. The objects are accessed as follows in text documents: The GetByIndex method returns the form with the index number 0. The two empty strings in the command line stand for the user name and password. Correspondingly, two different access methods are defined there for charts. If an error is made during the modifications, this can be undone using the cancelRowUpdates()method. The fill mode of a drawing object is defined using the FillStyle property. Unlike the data sources presented in the previous section, the database connection must therefore be re-established every time the program is restarted. If you want to use such a name, you must tell Basic where to look. The WithEnd With bracketing statements provide an alternative to writing out all the qualifiers, every time and some of the qualifiers in the API can be quite long. 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 a loop that passes through all the cells of a table and enters the corresponding row and column numbers into the cells. Each cell of a LibreOffice document has a unique name. The following example therefore displays a message that informs the user whether the Spreadsheet object contains a page of the name Sheet1. If the corresponding parameter is not present, then a default value (in this instance, the value 0) is passed to B_Local rather than the passed parameter. The Chart object provides the following properties for administrating these elements: Both services com.sun.star.chart.ChartTitle and com.sun.star.chart.ChartLegend do support the service com.sun.star.drawing.Shape. All formatting options for individual characters and paragraphs are therefore automatically available. The command: specifies the same delay, 2 seconds, as the previous example. The real API call is: Sheet.getColumns.getByIndex(1). Focus events indicate if a control element receives or loses focus. The elements in getByIndex however are numbered beginning with 0. These in turn can be linked to LibreOffice Basic macros to considerably extend the usage range of LibreOffice Basic. In addition to single dimensional data fields, LibreOffice Basic also supports work with multi-dimensional data fields. The control element can be reached using Event.Source and its model using Event.Source.Model. If it does, the method determines a corresponding object reference by using the getByName method and then saves the reference in a variable in Sheet. The replacement function of LibreOffice is particularly effective when used in conjunction with regular expressions. With the TypeEnd Type statements, you can define your own (non-UNO) structs: The Type definition is only a pattern or template, not a set of actual variables. If the center of a paragraph, for example, contains a word printed in bold, then it will be represented in LibreOffice by three paragraph portions: the portion before the bold type, then the word in bold, and finally the portion after the bold type, which is again depicted as normal. The FreeFile function is used to create a free file handle: FileNo is an integer variable that receives the file handle. The characters are not rotated. There is no type declaration symbol for date variables. This function is similar to the one that is used in text documents as described in #Text Documents. 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. As can be seen in the example, the insertTextContent method expects not only the Content object to be inserted, but two other parameters: Note: The declaration can only be made using the supplement As Boolean. 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. This guide provides an introduction to programming with LibreOffice Basic. Whereas in VBA the paragraphs are accessed by their number (for example, by the Paragraph(1) call), in LibreOffice Basic, the Enumeration object described previously should be used. The type of removal is defined by one of the following values from the com.sun.star.sheet.CellDeleteMode enumeration: The XRangeMovement interface provides two additional methods for moving (moveRange) or copying (copyRange) cell ranges. In LibreOffice Basic, the formatting properties on the other hand are available directly, using the relevant objects (TextCursor, Paragraph, and so on). The following values are available: The following example creates a circular slice with a 70 degree angle (produced from difference between start angle of 20 degrees and end angle of 90 degrees). 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. To make the fill transparent, set the FillTransparence property to 100. Then the new page is renamed. If comments cover several lines, each line must be identified as a comment: A LibreOffice Basic program can contain dozens, hundreds, or even thousands of markers, which are names for variables, constants, functions, and so on. Until Basic encounters the End With statement, it looks for partly-qualified names: names that begin with a period (unary dot-operator). Direct formatting always takes priority over indirect formatting. This event is initiated by either a key-press or a mouse button. For more information about the LibreOffice API and the Software Development Kit, visit https://api.libreoffice.org. The global name ThisComponent generally returns the same object as StarDesktop.CurrentComponent, with one significant advantage. In Example 1, the page is accessed by its number (counting begins at 0). Constants have the same scope as variables (see #Scope_of_Variables Scope and Life Span of Variables), but the syntax is slightly different. The reference CellStyles(I) corresponds to the method getByIndex(), which is optional for these style container objects. LibreOffice Basic dialogs consist of a dialog window that can contain text fields, list boxes, radio buttons, and other control elements. The following control codes are available in LibreOffice: To insert the control codes, you need not only the cursor but also the associated text document objects. You can also create data sources and work with them using LibreOffice Basic. The column objects support the com.sun.star.table.TableColumn service that has the following properties: The width of a column is only optimized when the OptimalWidth property is set to True. The basic structure of the example is oriented towards the examples for running though the paragraph portions of a text already discussed previously. There is, however, one main difference: a Universal Network Object may support several services at the same time. A database is incorporated into LibreOffice by creating what is commonly referred to as a data source. 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. The cell type is not determined by the content that is saved in the cell, but rather the object property which was used for its entry. An example for the grouped option button: Text fields allow users to type numbers and text. This example shows how you may define and use a struct, and how to reference the items within it, both with and without With. When working with spreadsheets, an intermediate stage is needed for the Sheets list because the drawing levels are not located directly in the document but in the individual sheets: As is already suggested by the GetByIndex method name, a document may contain several forms. The working memory needed for a string variable depends on the length of the string. If no more matches are found for the search term, the function establishes the part of the string still remaining and adds this to the return buffer. When specifying a service name, it is only the module name which is of any importance because this must be also listed in the name. The formatting properties can be found in each object (Paragraph, TextCursor, and so on) and can be applied directly. Every UNO object knows what properties, methods and interfaces it already contains. 3D charts usually also have a floor. Text frames are considered to be TextContent objects, just like tables and graphs. This is a transfer channel which permits direct communication with the database. LibreOffice Basic provides the following test functions for this purpose: These functions are especially useful when querying user input. Finally the code sets the Label property of the control element to the New Label value. The ResultSet object provides Update methods for modifying values, which are structured in the same way as the get methods for retrieving values. You specify the qualifiers in the With statement. In this example, the graphics are depicted as 40 percent transparent with no other color conversions do not take place (GraphicColorMode = STANDARD). The applications are: Writer (a word processor), Draw (vector graphics drawing), Impress (for slide presentations), Calc (spreadsheets), Base (a database front- end), and Math (for writing formulae). (When listing the service name of a text field, uppercase and lowercase characters should be used in LibreOffice Basic, as in the previous example.). A variant is a universal variable that can record all conceivable values, including strings, whole numbers, floating point figures, and Boolean values. VBA: Text frames are LibreOffice's counterpart to the position frame used in Word. Alternatively, if only an empty document without any adaptation is needed, a private:factory URL can be specified: The call creates an empty LibreOffice writer document. The shape object of the control element must already be known if the code is to function. Write the qualifiers in order, from outer to inner: These names may also be described as, "concatenated with the dot-operator ('.')". To avoid such blind events, save the old control element value in a global variable, and then check to see if the value has changed when an event is executing. When LibreOffice Basic encounters an incorrectly defined variable type in a particular context, an error message is generated. 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. The StyleFamilies are accessed by means of the document object: The example uses the StyleFamilies property of a spreadsheet document to establish a list containing all available cell styles. The computeFunction expects a constant as the parameter that describes the mathematical function that you want to use. Ability to open, edit, and save Microsoft Excel spreadsheets. The Expand parameter is a Boolean value which specifies whether the area passed over during navigation is to be highlighted. The LibreOffice Developer's Guide describes the LibreOffice API in more detail than this guide, but is primarily intended for Java and C++ programmers. Their respective logos and icons are also subject to international copyright laws. An integer variable can take up to two bytes of memory. The page properties that are valid for both types of documents are defined in the com.sun.star.style.PageProperties service. The first central line creates the Doc document variable, which references the current spreadsheet document (Doc line = StarDesktop.CurrentComponent). Charts within spreadsheets can display the data from an assigned cell range within the spreadsheet. An object which supports the com.sun.star.sdb.QueryDefinition service is concealed behind a query. There are four versions of the DoLoop. 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. The com.sun.star.frame.XStorable interface, which is responsible for saving documents. These are available through the Rows and Columns properties of the spreadsheet object and support the com.sun.star.table.TableColumns and/or com.sun.star.table.TableRows services. Automatic optimization continues until the row is assigned an absolute height through the Height property. You can also link another action to the button to close a dialog using the PushButtonType property. LibreOffice Basic provides the MkDir function for creating directories. The text frame created in this way can then be inserted in the document using the insertTextContent method of the Text object. LibreOffice Basic provides two methods for inserting comments in the program code: A comment usually includes all characters up to the end of the line. English documentation | LibreOffice Documentation - LibreOffice User Guides en / English documentation English documentation Getting Started Books Buy a printed copy Download PDF Guide Source Files Website Buy a printed copy Download PDF Download Source Files Read in your browser Buy a printed copy Download PDF Download Source Files However, unlike the old Application object, StarDesktop is primarily responsible for opening new documents. Strictly speaking, a PolyPolygon is not a simple polygon but a multiple polygon. The bookmarks of a text are accessed through a list called Bookmarks. If the corresponding page does not exist, it is created and inserted in the drawing document by the insertNewByIndex method. In the previous example, if the UserInput variable contains a valid numerical value, then this is assigned to the ValidInput variable. To prevent this effect, the user can access the associated paragraph portions rather than the entire paragraph. 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. If the field proves to be a date/time field or an annotation, then the corresponding field type is displayed in an information box. If you want to delete directory (including its files) use the RmDir function. As a parameter, this takes the name of the property and returns a constant that provides information about the origin of the formatting. Several common examples to tell users how to write macros in different applications. VBA: In terms of their function, the LibreOffice Basic insertCell, removeRange, and copyRange methods are comparable with the VBA Range.Insert, Range.Delete ,and Range.Copy methods. Unlike in the InsertCells method , a parameter for performing automatic moves is not provided in the moveRange method. Templates are auxiliary documents. This allows numbers to be handled in a manner which more closely reflects machine architecture. This is not, for example, possible with complex SQL commands with linked columns or accumulated values. Download PDF. Event-Driven Macros This section describes how to assign Basic programs to program events. VBA: The rules for constructing markers are different in LibreOffice Basic than in VBA. Dialogs such as this one are described as modal because they do not permit any other program action until they are closed. The lines are dark gray (Color) and are spaced is 0.2 millimeters (Distance) apart. A loop executes a code block for the number of passes that are specified. While this dialog is open, the program remains in the Execute call. A struct is an ordered collection of data fields, that can be manipulated as a single item. The majority of these properties are defined in the com.sun.star.text.BaseFrameProperties service, which is also supported by each TextFrame service. The type declaration symbol for a long integer is &. The steep learning curve is not imposed by your chosen language. The following values are available: The following example computes the average value of the A1:C3 range and prints the result in a message box: The clearContents method simplifies the process of deleting cell contents and cell ranges in that it deletes one specific type of content from a cell range. 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. The declaration. The Replace function used for replacing does not fall within the standard linguistic scope of LibreOffice Basic. LibreOffice Basic lets you define parameters as optional, that is, if the corresponding values are not included in a call, LibreOffice Basic passes an empty parameter.
Muddy Paws Rescue Omaha,
Is Turkey Clean Or Unclean According To The Bible,
Alaya Boyce,
Auspicious Days In August 2022,
Hotels Near 225 Rogers St Ne Atlanta, Ga 30317,
Articles L