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 OpenOffice.org [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.
Post Reply
User avatar
Villeroy
Volunteer
Posts: 30687
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Print properties of TypeDetection and FilterFactory

Post by Villeroy »

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

((com.sun.star.beans.PropertyValue){ Name = (string)"en-US", Handle = (long)0x0, Value = (any){ (string)"OpenOffice.org 1.0 Presentation Template" }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE },)
Attachments
reportFileTypes.odt
(26 KiB) Downloaded 244 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
Post Reply