오픈오피스 파이썬확장 수련 ====== install ====== 다음 패키지 설지: $ sudo apt-get install python-uno 오픈오피스는 아래 위치에 설치되어 있음: /usr/lib/openoffice/ 다음 명령어로 동적 라이브러리 갱신 필요? $ sudo ldconfig -v /usr/lib/openoffice/program ====== hello world ====== 우선 오픈오피스를 다음처럼 실행 soffice "-accept=socket,host=localhost,port=2002;urp;" 다음으로 아래의 코드 실행 #!/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 ====== ooclac ====== 그냥 ooclac 실행하고 해도 되나?? #!/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) ====== 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 ====== *[[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/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 예제 많음!!