How to copy cell's contents into a main document?

I need to automate the following actions:

For each table, extract the contents of the first cell (“A1”) and paste just before the table.

    localContext = uno.getComponentContext()
    resolver = localContext.ServiceManager.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", localContext
    )
    ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
    instance = subprocess.Popen(" ".join(
                [
                    "/usr/bin/soffice",
                    '--accept="socket,host=127.0.0.1,port=2002;urp;StarOffice.ServiceManager"',
                    "--norestore",
                    "--nologo",
                    "--nodefault",
                ]), shell=True)

    smgr = ctx.ServiceManager
    desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
    uno_path = uno.systemPathToFileUrl(str(doc_path))

    doc = desktop.loadComponentFromURL(uno_path, "_blank", 0, ())
    xTables = doc.getTextTables()
    for xTable in xTables:
        oCell = xTable.getCellByPosition(0, 0)
        oVC = doc.getCurrentController().getViewCursor()
        oVC.gotoRange(oCell, False)
        oVC.goUp(1, False)
        oEnum = oVC.getText().createEnumeration()
        oPrevPar = None
        oNextPar = None
        noteTable = False

        if len(xTable.DataArray) == 1 and len(xTable.DataArray[0]) == 2 and xTable.DataArray[0][0].lower() == "note":
            noteTable = True
            oEnum = oVC.getText().createEnumeration()
            oPrevPar = None
            oPar = None
            while oEnum.hasMoreElements():
                oPrevPar = oPar
                oPar = oEnum.nextElement()
                if oPar == xTable:

                    oPrevPar.Text.insertTextContent(oPrevPar.Text.getEnd(), xTable.getCellByName("A1"), True) # Does not work

Please note, that I want to copy not only the cell’s text, but also all the complicated mosaic of formatting.

please, add a test file for help you.

Here is my solution using Basic

sub copyFancyTableText
	Dim doc: doc = ThisComponent
    Dim xTables: xTables = doc.getTextTables()
    
    Dim xTable,oCell,oVC,oEnum,oPrevPar,oNextPar,noteTable,oPar
    Dim oFrame,oDispatcher 

	'Prep visual cursor
	oVC = doc.getCurrentController().getViewCursor()   
            
	'Dispatcher bits for clipboard functionality
	oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	oFrame = ThisComponent.CurrentController.Frame
	
    for each xTable in xTables
        oCell = xTable.getCellByPosition(0, 0)

        oVC.gotoRange(oCell, False)
        
		'Copy cell
		oDispatcher.executeDispatch(oFrame, ".uno:Copy", "", 0, Array())
        
        'Move VC up, above table.
        oVC.goup(1,false)
        
        oDispatcher.executeDispatch(oFrame, ".uno:Paste", "", 0, Array())
        
	next		
end sub

Here are the results,