Hi * On Wed, Jan 9, 2013 at 11:40 AM, Jürgen Schmidt <jogischm...@gmail.com> wrote: > On 12/19/12 3:04 PM, Robert Barbey wrote: >> Hi everyone, >> >> is it possible to get the kind of document currently opened in Writer via >> the API? Ideally, this would be a MIME type kind of thing. >> > > sorry for answering so late but I forget it and stumbled over this now > again. But the bad news is that I don't know it for sure but it seems > that it not possible.
The model has a getArgs() method http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/TypeDetection.html that returns a MediaDescriptor, look for "FilterName" in that array http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/MediaDescriptor.html#FilterName then use the TypeDetection to get the filter information by name, and search for "MediaType" http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/TypeDetection.html Sample Basic code: REM ***** BASIC ***** Option Explicit Sub Main Dim oDoc as Object oDoc = ThisComponent Dim aArgs() aArgs = oDoc.getArgs() Dim sFilterName$ Dim i% For i = 0 To UBound(aArgs) If aArgs(i).Name = "FilterName" Then sFilterName = aArgs(i).Value Exit For End If Next Dim sMime$ Dim oTypeDetection as Object oTypeDetection = CreateUnoService("com.sun.star.document.TypeDetection") If oTypeDetection.hasByName(sFilterName) Then Dim aFilter() aFilter = oTypeDetection.getByName(sFilterName) For i = 0 To UBound(aFilter) If aFilter(i).Name = "MediaType" Then sMime = aFilter(i).Value Exit For End If Next End If MsgBox "Mime " & sMime End Sub Regards