Property :: createDocument - Create document
In order to fill documents with database content, document templates have been introduced, which allow complex document definitions. Even though document templates finally result in ordinary OSI expressions, handling document templates requires specific support, which is provided by an Open Document library ( OpenOffice.dll ). The library creates OSI functions from Libre Office document templates, but also converst QT HTML used in RTF controls into Open Document XML.
In order to create a document, the template path must be passed in sTemplate . The target location for the document has to be provided in sDocument . When the target file already exists, it will be overwritten. When the target file exists and is opened, the function call returns an error ( false ).
Usually, the offset instance for creating the document is the instance selected for the property handle. The data type for the selected instance and the function scope for the entry point in the document template must be the same or the instance type must inherit from the main function scope. When not defining a scope for the main function, the the function is considered as belonging to VOID class. One may access the property handle within the template functions, but type checks have, usually, to performed in this case.
The main function name must be the same as the template file name (without extension). When the main function does not requires an starting object instance, one may call the function with any valid property handle, but a valid property handle is always required by the function. When the calling object is not a valid property handle, the function throws an exception.
... fragment ( Property &person ) {
String doc ("documents/");
doc += person.name() + ".odt";
person.createDocument("templates/person.odt",doc);
}
In principle it also works for MS open document files, but this is not save. A better way is using Libre Office templates and converting documents to MS office documents after being created.
The value is true when the function was executed successfully. Otherwise the value is set to false .
Implementation details
- sTemplate
- Template path
The string contains the complete path for the template.
- sDocument
- Document path
The string contains the complete path for the document.