Print properties of TypeDetection and FilterFactory

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

Print properties of TypeDetection and FilterFactory

Postby Villeroy » Sun Feb 24, 2019 8:53 pm

The attached text document contains the source code of a Python macro and an installation routine in StarBasic. If the document is allowed to run its embedded StarBasic macro, the Python code will be installed by a push on a button. Then it can be called via Tools>Macros>Run... "My Macros">reportFileTypes>Main or via Tools>Macros>Organize>Python>"My Macros">reportFileTypes>Main
The Python macro generates a spreadsheet document with sheets "TypeDetection" and "FilterFactory".
Then it prints all elements of the respective service and the property values of these elements into the respective sheet.
The printed information includes all filter names, user interface names, the service names of filter dialogs, file name extensions, clipboard formats and many things I don't understand neither. You may run it after you installed either a new version of your office suite or some extension package providing new file filters. The resulting tables should help you to write your own macros/extensions.
Unless the property values are plain numbers or strings, Python's string representation of the property value will be printed into the respective cell. For instance, (u'docx',u'docm') is the representation of an array with two unicode strings docx and docm in Python2 (OpenOffice). In Python3 (LibreOffice) all strings are unicode anyway and the same string array is shown without "u": ('docx','docm').
The following is Python's string representation of an UNO object, namely a c.s.s.beans.PropertyValue describing a UI name in UI language "en-US":
Code: Select all   Expand viewCollapse view
(({ Name = (string)"en-US", Handle = (long)0x0, Value = (any){ (string)" 1.0 Presentation Template" }, State = ( },)
(26 KiB) Downloaded 139 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Posts: 29460
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest