User Tools

Site Tools


pyuno

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
pyuno [2010/07/21 01:20] – created suapapapyuno [2013/08/03 05:04] (current) – external edit 127.0.0.1
Line 1: Line 1:
 오픈오피스 파이썬확장 수련 오픈오피스 파이썬확장 수련
- +====== install ====== 
-오픈오피스는 아래 위치에 설치되어 있음+다음 패키지 설지: 
 +<code bash> 
 +$ sudo apt-get install python-uno 
 +</code> 
 +오픈오피스는 아래 위치에 설치되어 있음:
 <code> <code>
 /usr/lib/openoffice/ /usr/lib/openoffice/
Line 9: Line 13:
 $ sudo ldconfig -v /usr/lib/openoffice/program $ sudo ldconfig -v /usr/lib/openoffice/program
 </code> </code>
 +
 +====== hello world ======
 +우선 오픈오피스를 다음처럼 실행
 +<code bash>
 +soffice "-accept=socket,host=localhost,port=2002;urp;"
 +</code>
 +다음으로 아래의 코드 실행
 +<code python>
 +#!/usr/bin/python
 +# -*- coding: utf-8 -*-
 +
 +import uno
 + 
 +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" )
 +smgr = ctx.ServiceManager
 +desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
 +model = desktop.getCurrentComponent()
 +text = model.Text
 +cursor = text.createTextCursor()
 +text.insertString( cursor, "한글로 안녕~".decode('utf-8'), 0 )
 +
 +ctx.ServiceManager
 +</code>
 +====== ooclac ======
 +그냥 ooclac 실행하고 해도 되나??
 +<code python>
 +#!/usr/bin/python
 +
 +import uno
 +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" )
 +smgr = ctx.ServiceManager
 +desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
 +oDoc = desktop.getCurrentComponent()
 +
 +# sheet to be activated
 +oSheet = oDoc.getSheets().getByIndex(2)
 +
 +# activate the sheet
 +oController = oDoc.getCurrentController()
 +oController.setActiveSheet(oSheet)
 +
 +# set first visible row
 +oController.setFirstVisibleRow(3)
 +</code>
 +
 +====== ooimpress ======
 +UNO service : com.sun.star.presentation.SlideShow
 +  *[[http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/Presentation2.html|service Presentation2]]
 +  *[[http://www.oooforum.org/forum/viewtopic.phtml?t=54716|ooimpress: slide show. Python]]
 +  *[[http://wiki.services.openoffice.org/wiki/Slideshow|Slideshow]]
  
 ====== references ====== ====== references ======
 +  *[[http://api.openoffice.org/docs/common/ref/com/sun/star/frame/Desktop.html|service Desktop API]]
   *[[http://wiki.services.openoffice.org/wiki/Using_Python_on_Linux|Using Python on Linux]]   *[[http://wiki.services.openoffice.org/wiki/Using_Python_on_Linux|Using Python on Linux]]
 +  *[[http://wiki.services.openoffice.org/wiki/PyUNO_bridge|PyUNO bridge]]
 +  *[[http://lucasmanual.com/mywiki/OpenOffice|OpenOffice]] another good reference
 +  *[[http://m10s.blogspot.com/2010/07/select-activate-sheet-in-calc-by-python.html|select (activate) a sheet in openoffice calc by python code]] oocalc 예제 많음!!
pyuno.1279675245.txt.gz · Last modified: 2013/08/03 05:04 (external edit)