 Go ahead, you're going to be talking about script for it. Okay, so you see my slides. Yes, yes we do. Okay then. Well my name is Jean-Pierre Le Dure and I contribute to LibreOffice since 2013, something like that, mainly with the access to base library which is now a very major part of the basic libraries which are shipped with LibreOffice. And we started a new initiative which is called Scriptforge. You know what Forge is in software engineering and the target is to have something for authors of scripts, either written in basic or in Python. You see that Python is between square brackets because in the first release Python coders have no benefit from Scriptforge but they'll have in the future. The code exists, so show the code, you can see it on GitLab. We will see what Scriptforge is in a nutshell and then also raise the question is it smart to code an API because it's an API. We offer a number of services with Scriptforge and the API is mainly written in basic, not only, there are also parts of it written in Python. Service and framework go together. The code is subdivided in services and the integration is done via a framework and this makes the thing also extensible in the sense that the framework can integrate new services if needed, also written by other persons than myself or the other people who work with me. We will see what the modules will contain in the first release which will be shipped with LO 7.1 and what we plan for the future. What is it in a nutshell? It's a service-oriented framework. We have implemented so far something like 300 methods and the question was how can we make them coexist? Well, we separated them in silos and we called them services. We will see why and how and to make the whole thing extensible, we built the framework. What we will have know immediately as functionalities, we extended the arrays and the strings containers with a huge number of functions and we implemented also a mapping class called dictionary which is larger than the correction class which is included in basic. Error handling is also weaker than VBA anyway and we extended it also. We built a complete files and folders management class and also read and write to text files because how to do it in basic is quite rudimental. Localization also, localization is done with a number of functions and we use the PO portable object format for that. There are a number of functions to integrate basic and Python and then more classically a number of classes also to manage Windows documents in particular calc sheets also dialogues and their controls and how to access databases. Mainly for the last ones, documents, dialogues and databases, the idea is not to replace UNO, it's to make wrappers that facilitate the access to UNO. So an API written in basic is that smart? Well, the first question is can we handle complex data structures in basic? Well, the answer is yes. A variant can contain anything and you can including user defined types and user defined types can contain variants themselves and etc. So that makes the stretching of data of information quite easy and quite complete. Now another question was is there object orientation in basic? Well, the answer is partially yes. You can encapsulate methods and properties in a class module that works but there is no subtyping. It can be bypassed. For instance, we use that for making the color class subtype of the document class. But it's bypassed, it's not built in. And of course basic variable tags, a string is not an object in basic. So it's quite limited but sufficient to do a number of things and an important property of this is that you can encapsulate methods and properties. There are no namespaces in basic and even public and private attributes are ignored. So this makes things a bit difficult to have a very large API. But there also we worked a bit on that. Important is that the next slide. What was really blocking is that when you load a new library into basic, well, all the functions present in that new library are de facto public from anywhere in the libraries that you have already loaded before. So this makes that you never assure when you call a function by its name that you execute the function that you think should be executed now. Accept it if you fully qualify the function with global scope probably. The library name, dot the module name, dot the function name. But happily we discovered that it was in fact really easy to work around that. You can assign a module which is a useful basic object to a variable and execute any function just by qualifying it with a variable which has received the module as content. Okay, that was a number of prerequisites that we had to build what we did. And now the user's point of view is quite easy. The user must of course now to start with scripting and using the services that we provide. Well, of course the script for library has to be loaded. That's a matter of this application in basic. And afterwards if that is done, the user will call a method name is create script service. Of course the analogy with create unit service is obvious and it's intentional. The user has to call create script service for instance for service called file system which gives and then access to a number of methods for instance, copy file, delete folder. These words in many cases very long method names and it simplifies for the user the use of our services and prevents any collision between homonyms. Besides create script service we as a tolerance we allow to use because we think that there will be a use frequently to directly call the modules for arrays, strings and exceptions. And so it's equivalent to write create script service array or sf array dot so. Okay, but you spare a number of lines of code. Okay, that's what the user has to know. The create script service will then return either a basic module as an object or a basic object, a basic class instance. In fact, and in the latter case, arguments may be passed to the constructor of instance. So from now on if you want to use a method from script for as you qualified. How is that implemented? Well, you see the three levels. You have the user script, you have the core of script for and you have a library. And the three parts here may be written by three different persons. The user is probably someone someone else. But script for score and my library my library can be any library who wants to play the game. Well, the user script cause create script service and the core will, of course, contain the method create script service. What will that method do? Well, once of course, the my library, which is the library called by the user must be loaded, but this is done by by the API script force will search for a method called register script services in my library. And then we'll return this, the requested service. And the register script services is a mandatory method that must be implemented as supporting in the requested library. And in that method, the author of that mail of the library, which can be an extension, for instance, will enumerate the services that it implements very easily, either as a module for the example of my service one, or as a string giving the method that must be called by script force core when the user requests the service to get an instance of that specific service. So the framework here is quite easy. The goal is to have from basic scripts, one unique create script service method, and the same method from in the future from Python scripts. This makes that the challenge will be to have services come on to Python and to basic implemented either in Python or in basic. The framework for the basic part, which is today, you can see there the core implements create script service implements register service and register event manager. I did not talk about register event manager, except the fact that you can get services when a code is triggered by events as well. And an associated library or an invited, we call it that way, an extension, for instance, must minimally implement register script services and optionally a number of other things which make things easier. Pythonists, they are really, really easy to write. Pythonists will recognize the REPR routine, which asked the service to give a textual representation of the content of a specific instance. But the idea is well to have common services both from basic and from Python. So to have finally the core library, a number of associated libraries, and what the green part and the blue part will be shipped in the first release and optionally all the candidates to make new libraries in the future or wanting to make extensions and using the classes of script force can make extensions and can just be integrated in the whole framework by implementing the registering of the new services he wants to implement. Now what is present in the first release that we will ship with LO7.1? Well, four, basic libraries you recognize with the elements that I mentioned before. So SF documents is the name of a library where Calc is the name of a service. So four basic libraries and a number of Python helper functions. We'll see where in the next slides. There is also one online help page like you know them with LibreOffice by service and one English POT file. What is POT? The sportable object template file for preparing the translation of all the labels that we use in the software. There is also a complete unit test suite which will not be integrated in LibreOffice in the first step, but it exists and there is also a coding convention charter for future contributors. As an example of the help page, you see that's quite detailed as the name of the library is SF databases and database in the name of service and you see for instance here how can you invoke a service with a number of arguments etc. And you have all the methods and all the properties which are detailed with examples below. So again the libraries and the services you see the green blocks are implemented as modules and the blue blocks are implemented as classes. Of course there are sometimes a number of methods that give of that return themselves another class or another object. Some of them you can be reached either for instance I take here the user interface. You can use the method open document to get a document object. You can object. You can also get the document object directly via create script service if you find it easier. Okay now we go through the different services as implemented so far. So the array service we have implemented 30 methods in it. The target is our 1d arrays or vectors and 2d arrays, two dimensions, and matrixes. You see that the verbs are quite easy to learn and to remember. You can manipulate data, you can transform the array, you can sort. For instance you can also sort rows on a column or sort columns on a row. You can search arrays, you can manipulate arrays as sets, making the union, reducing the array with only unique items, etc. And you can also import and export. For instance you can directly import the csv file into an array or convert, I take the last one here, convert the array into a dictionary, so a mapping class which is precisely the next topic. Basic contain collections today, well collections have a number of restrictions and implemented dictionaries here. Exactly like Microsoft did in the past, Microsoft also offers dictionary and collections. This is much more flexible than collections and we have almost, I say 90% mapped the interface as onto the VBA dictionary class here. We provide also a number of conversions from dictionaries to something else, in particular to JSON, this is done with a Python specific function, also conversion from property values, two property values and importing from property values. Why convert and not export? Because convert means you add something to what exists already. No, it's the opposite. Import means that you add to what exists new property values in this case or converting a dictionary to an array. As an example, the management of the services or the framework is implemented with a dictionary of dictionaries. A first dictionary of libraries and a second one of all the services provided by that specific library. We provide an exception service. Here is an example of the output as displayed to the user when race fatal is executed by script for us because script for us detected some anomalies. You see the library, the service, the method, in this case sort, and you see the syntax of the interface used by the user. And in some of the arguments that was something wrong, the validation, the validation rules are reminded here. So the order must be a string and containing one of the next values. And unfortunately, it contains something else. So the execution is cancelled. So the user friendliness of the API that we provide is illustrated here. You will notice also that this is here in English. Everything there can be localized. Here to fill the gap with the VBA air object, we did a number of things. Well, the time goes further. I will not detail here what the possibilities are. Also, still about exception. There is a console that is provided. A console is filled with an execution of a number of debug print statements. A debug print will can have as many arguments as you want and will display in a model or non-module dialogue what happens and what happens during the execution. It's, in fact, particularly useful when you execute, for instance, use a defined function from a calc formula. Well, you cannot use the IDE to debug your function. You have to use, you can use, in this case, in non-module mode, the console. You have also file system service. It's mapped on what VBA offers. I can underline here a number of verbs with wildcards where the arguments can contain wildcards. You have also a number of functions executed by Python. You can, for instance, get the md5 or something or another hash code from the file that you give us as argument. It then for compare files. The text stream class is quite easy and quite obvious. The difference with what the basic office standard is that you can set the new line and the encoding specifically by file. Now the L10N service is quite original, I think. For those who know, I don't know who knows what the PO file is, but it's a technique imagined by GNU to separate the two profiles between the programmer who writes a number of labels in his language or in English and the translator who translates all the strings in a specific file. What we provide here is a method at text, a method export to port file, which generates the template file, and when at runtime get text will allow to get from a PO file, so a translated file, the correct translation. Platform is a mapping of the Python platform.py library. In the session service we put what we could not put elsewhere, so we put there a number of unobjects, introspection methods, a send mail method in particular, also interfaces to easily execute external programs, either in Python, either a calc function or running an application based on the suffix of the file that you provide as argument. Also executing a web service or open some URL in your browser. All these methods here are examples, there are more in fact. Confront here we have a total 42 methods to work on strings, for instance to replace such strings, so basic as a replace method, but replace STA will work on arrays of strings, replace char will work on substitution one by one of characters in input and output strings. We have a collection of input validation functions, for instance is ex-digit, is a string that you provide ex-digit, is it IPv4, is it a URL, is it a white space, which is much more than space, is it a regular expression or does it fit with given regular expression. Item to parse strings here, find regular expression in a string, replace all occurrences of a regex by something else, or split not quoted, they're quite useful when for instance you want to parse CSV file, well the CSV file has a number of chunks of strings separated by commas and a chunk when it is surrounded with quotes can contain commas, what do you do? Well you split not quoted and you give the commas a separator and you get the chunks in the array. Working with line break special characters, also hashing, also done in Python, and we were inspired by what Python and PHP in particular offer or propose here. We have also implemented in the core a timer which measures elapsed time, it's to compare the performance in duration between different algorithms if needed. So you can for instance start a timer, suspend it just before displaying a message box, waiting for the okay and then continue again and continue again up to extermination and measure then what was the effective duration for the significant part of what you want to measure in terms of performance. And using interface service manages windows and documents, you have a number of things proposed here, also progress bars you can put the progress bar or text in status bar, you can also display dialogue which shows a progress bar during which you can well do a number of things and give the progress on the dialogue. It's from there that you start document instances with here a number of methods. Of course base documents are often different from the other types of documents that's why there are specific methods also. And get document is for instance to get a class when you give let's say entitled to as argument when you get a document and you go forward and you can reach that way in the asset documents library, the document service. With a number of things that are classical to do on documents particularly here is that we convert immediately document properties or custom properties into a dictionary. You use the dictionary verbs if you want to update them and you can write them back in the document. You see here property X component well the component you know object that you know can be reached just by giving X component yours. We always use the X as prefix to designate use objects. It's just a shortcut to reach the document in the component mapped onto the document that it is about here in this instance. And we implemented in particular we did nothing about write the progress etc but we developed mainly here a number of things around calc sheets and we extended the concept of range. Range is always a stream the sheet and then like you see here sheet X dot etc the range is given as usual but to extend it you can for instance use a star instead of the real coordinates just by the star replaces the used area on the sheet and you can also use the tilt to designate the current selection and you can also use a specific method called range to get an object for instance if you want to copy a range from file A to file B and well from sheet X to the current sheet on this with this coordinates well it's done in one statement. You have also shortcuts you see X spreadsheet or X star range and you can also have here a number of import import verbs to fill sheets. The focus here is really on filling sheets with data and not formatting them. The only verb that you have to format data is set cell style. Here for database well you can mainly get selective data with these verbs here and you can get you get one single value or you can get massive data with get rows and you get an array of data. Of course conversion of I don't know date values in databases towards date values in basic is not automatic. You can also run action SQLs let's say updates or create table whatever you can you can execute them directly with run SQL as verb and then you have also shortcuts to a number of you know objects to go further if needed. Item for dialogues what is specific is that the dialogue can be displayed in non-modal mode in that case where the execute must mention that the argument is true and means that you want it in non-modal mode in that case while the execution goes just further up to the termination of the dialogue. You see to get the dialogue you just to create script service as usual with a number of arguments which dialogue etc and the controls method gives them access to the individual controls. Both for dialogues and for controls we do not make any distinction between the view and the model so it's a simplification. Also all the all the controls here whatever that type have the same exactly the same properties in particular take value where you use value to get or set the value of a control whatever it's its type you don't you don't need to know what its specific property is it's just a simplification and you have also shortcuts to control modern and console view. So this will be my last slide and I'm over my time so the perspectives are mainly to have a number of services typically for Python or philosophy is that if you want to display a message box in Python well the easiest way to do it and to have and to not have any visual difference with basic is to let it do in basic and to get the return value back item for dialogues etc and then the next challenge is will be to have the services common to Python in basic so that we can use basic services developed in basic or services developed in Python from anywhere. Okay I thank you. Thanks Jean-Pierre.