openoffice: duplicating rows of a table in writer

回眸只為那壹抹淺笑 提交于 2019-12-07 03:12:25

The solution is to use controller's method .getTrasferable() to get data from the ViewCursor. that in turn requires that you control your view cursor and position it in every single cell (I was not able to make the ViewCursor span multiple cells). Once you have acquired the transferable you place the cursor in the destination and insert.

  desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
  document = desktop.loadComponentFromURL("file://%s/template-debug.odt" % os.getcwd() ,"_blank", 0, ())
  controller=document.getCurrentController()
  table = document.TextTables.getByIndex(0)
  view_cursor=controller.getViewCursor()


  src = table.getCellByName(src_name)
  dst = table.getCellByName(dst_name)

  view_cursor.gotoRange(src.Text, False)
  txt = controller.getTransferable()
  view_cursor.gotoRange(dst.Text, False)

  controller.insertTransferable(txt)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!