c.s.s.text.MailMergeType.SHELL (4)

What is a “document shell” is in the context of LibreOffice: com::sun::star::text::MailMergeType Constant Group Reference

It means “a new generated single document in the editor, not saved anywhere”.

Thank you. Found another thing that does not work.

In https://bugs.documentfoundation.org/show_bug.cgi?id=150233 mikekaganski wrote:

The code does create a document, and it is returned from execute(). The result of the execute depends on the OutputType, and in a boolean indicating success, except for css.text.MailMergeType.SHELL, in which case it returns a XTextDocument

I did not expect an UNO method returning different types. Does anybody know how to load that document into a new application window (frame?), so an assumed user can do something with it?

Please check if https://wiki.documentfoundation.org/Documentation/DevGuide/Office_Development#Frames helps (I didn’t read it thoroughly myself, sorry, just judge based on the " Linking Components and Windows" and “Frame-Controller-Model paradigm” wording in the beginning, which is the correct direction).

Python code:

    rv = mm.execute(())
    #if uno.isInterface(rv):
    model = goffice.StarDesktop.loadComponentFromURL('private:factory/swriter', '_blank',0,())
    b = model.CurrentController.attachModel(model)

Returns True, when obj is a class of a UNO interface.

I had to comment out if uno.isInterface(rv): because it returns 0, no matter which UNO thingy I throw at it. Could this be a bug?
The new text document is loaded, the model is attached with return value True but nothing becomes visible.

What is actually working: storeAsURL and then load the resulting file.

Hum, I would expect that you don’t need a new model - the rv (XTextDocument) is already a model, and a component. Maybe it needs a controller, I don’t know … and then, a frame needs to be created and attached somehow.

Maybe Creating Frames Manually could also be relevant.

That is nonsense, of course.

And the following creates flawless output document and a new blank Writer window .

    rv = mm.execute(())
    model = goffice.StarDesktop.loadComponentFromURL('private:factory/swriter', '_blank',0,())
    view = model.getCurrentController()
    b = rv.setCurrentController(view)

https://wiki.documentfoundation.org/Documentation/DevGuide/Office_Development#Creating_Frames_Manually is too complicated to be explored by a simple mind. I’ll prompt a SaveAs dialog and then load the file.

Reading its implementation (and the method that it calls), it looks really odd. It seems to look for exact object in a generic “interface list”, which IMO would be wrong for anything except “meta-objects representing abstract interfaces” … I suppose it needs close examination of the expected use, and possibly documentation clarification and/or fixing of the implementation.


And this is what I get:

    '   -------------

Gosh! I saw the frame’s read-only property “Hidden”.
Indeed, this works. Very useful. I’ll make this the default when no option is given.
Thank you.

That would give the exact same result as OutputType FILE with no additional output options.

1 Like

I came up with this out of interaktive Python-session:

# uno is already imported 
from com.sun.star.text.MailMergeType import SHELL
from com.sun.star.sdb.CommandType import TABLE

template_URL = 'file:///home/ … /Documents/merge_biblio.odt'
target_URL = 'file:///home/ … /Documents/target2.odt'

# createUnoService is already defined!
mm = createUnoService("com.sun.star.text.MailMerge")

mm.DataSourceName = "Bibliography"
mm.CommandType = TABLE
mm.Command = "biblio"
mm.DocumentURL = template_URL
mm.OutputType = SHELL
mm.SaveAsSingleFile = True
doc = mm.execute((),)
doc.storeAsURL(target_URL, () ) #cannot storeAs  `template_URL`!