# Функция show_all_docs() выводит в окне сообщения имена всех открытых документов 
import uno
from com.sun.star.beans import PropertyValue

CTX = uno.getComponentContext()
SM = CTX.getServiceManager()


def create_instance(name, with_context=False):
    if with_context:
        instance = SM.createInstanceWithContext(name, CTX)
    else:
        instance = SM.createInstance(name)
    return instance

def msgbox(message, title='AlterOffice', buttons=1, type_msg=0):
    toolkit = create_instance('com.sun.star.awt.Toolkit')
    msgbox = toolkit.createMessageBox(Desktop.getFrames()[0].getContainerWindow(), type_msg, buttons, title, message)
    return msgbox.execute()

def show_all_docs():
    desktop = create_instance('com.sun.star.frame.Desktop', True)
    for doc in desktop.getComponents():
        msgbox(doc.Title)
    
    
Desktop = create_instance('com.sun.star.frame.Desktop', True)