forked from openlp/openlp
Clean up cnvdb
Start on Presentation Plugin code for Impress
This commit is contained in:
parent
69df159f17
commit
92b1b82a58
34
cnvdb.py
34
cnvdb.py
@ -1,4 +1,25 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
"""
|
||||||
|
OpenLP - Open Source Lyrics Projection
|
||||||
|
Copyright (c) 2008 Raoul Snyman
|
||||||
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
import codecs
|
import codecs
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Convert():
|
class Convert():
|
||||||
@ -8,16 +29,17 @@ class Convert():
|
|||||||
def process(self, inname, outname):
|
def process(self, inname, outname):
|
||||||
infile = codecs.open(inname, 'r', encoding='iso-8859-1')
|
infile = codecs.open(inname, 'r', encoding='iso-8859-1')
|
||||||
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
||||||
count = 0
|
|
||||||
for line in infile:
|
for line in infile:
|
||||||
writefile.write(line)
|
writefile.write(line)
|
||||||
if count < 150:
|
|
||||||
print line
|
|
||||||
count += 1
|
|
||||||
infile.close()
|
infile.close()
|
||||||
writefile.close()
|
writefile.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print 'No action specified.'
|
||||||
|
sys.exit()
|
||||||
|
print u'Uncode conversion '
|
||||||
|
print u'Input file = ', sys.argv[1:]
|
||||||
|
print u'Output file = ', sys.argv[2:]
|
||||||
mig = Convert()
|
mig = Convert()
|
||||||
mig.process(u'/home/timali/.local/share/openlp/songs/songs.dmp',u'/home/timali/.local/share/openlp/songs/songs.dmp2')
|
mig.process(sys.argv[1:],sys.argv[2:])
|
||||||
|
@ -21,5 +21,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
from filelistdata import FileListData
|
from filelistdata import FileListData
|
||||||
from mediaitem import PresentationMediaItem
|
from mediaitem import PresentationMediaItem
|
||||||
from presentationtab import PresentationTab
|
from presentationtab import PresentationTab
|
||||||
|
from impresscom import Openoffice
|
||||||
|
|
||||||
__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab']
|
__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab', 'OpenOffice']
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
#from win32com.client import Dispatch
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
"""
|
||||||
|
OpenLP - Open Source Lyrics Projection
|
||||||
|
Copyright (c) 2008 Raoul Snyman
|
||||||
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
# OOo API documentation:
|
# OOo API documentation:
|
||||||
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
|
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
|
||||||
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
|
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
|
||||||
@ -7,15 +24,55 @@
|
|||||||
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
|
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
|
||||||
# http://mail.python.org/pipermail/python-win32/2008-January/006676.html
|
# http://mail.python.org/pipermail/python-win32/2008-January/006676.html
|
||||||
|
|
||||||
class ImpressCOMApp(object):
|
import os , subprocess
|
||||||
|
import time
|
||||||
|
import uno
|
||||||
|
|
||||||
|
class Openoffice(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.startOpenoffice()
|
||||||
|
|
||||||
|
def createResolver(self):
|
||||||
|
self.localContext = uno.getComponentContext()
|
||||||
|
self.resolver = self.localContext.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', self.localContext)
|
||||||
|
try:
|
||||||
|
self.ctx = self.resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def buildEnvironment(self):
|
||||||
|
self.smgr = self.ctx.ServiceManager
|
||||||
|
self.desktop = self.smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", self.ctx )
|
||||||
|
self.model = self.desktop.getCurrentComponent()
|
||||||
|
text = self.model.Text
|
||||||
|
cursor = text.createTextCursor()
|
||||||
|
text.insertString(cursor, "Hello world", 0)
|
||||||
|
self.ctx.ServiceManager
|
||||||
self.createApp()
|
self.createApp()
|
||||||
|
if self._sm == None:
|
||||||
|
# start OO here
|
||||||
|
# Create output log file
|
||||||
|
time.sleep(10)
|
||||||
|
self.createApp()
|
||||||
|
|
||||||
|
def startOpenoffice(self):
|
||||||
|
cmd = u'openoffice.org -nologo -norestore -minimized ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
|
||||||
|
retval = subprocess.Popen(cmd, shell=True)
|
||||||
|
self.oopid = retval.pid
|
||||||
|
|
||||||
|
def checkOoPid(self):
|
||||||
|
procfile = open("/proc/%d/stat" %(self.oopid))
|
||||||
|
if procfile.readline().split()[1] == u'(soffice)':
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def createApp(self):
|
def createApp(self):
|
||||||
try:
|
try:
|
||||||
self._sm = Dispatch(u'com.sun.star.ServiceManager')
|
|
||||||
self._app = self._sm.createInstance( "com.sun.star.frame.Desktop" )
|
self._app = self._sm.createInstance( "com.sun.star.frame.Desktop" )
|
||||||
|
print "started"
|
||||||
except:
|
except:
|
||||||
|
print "oops"
|
||||||
self._sm = None
|
self._sm = None
|
||||||
self._app = None
|
self._app = None
|
||||||
return
|
return
|
||||||
@ -35,6 +92,7 @@ class ImpressCOMApp(object):
|
|||||||
self._sm = None
|
self._sm = None
|
||||||
|
|
||||||
class ImpressCOMPres(object):
|
class ImpressCOMPres(object):
|
||||||
|
|
||||||
def __init__(self, oooApp, filename):
|
def __init__(self, oooApp, filename):
|
||||||
self.oooApp = oooApp
|
self.oooApp = oooApp
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
@ -111,8 +169,9 @@ class ImpressCOMSlide(object):
|
|||||||
return self.preview
|
return self.preview
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ooo = ImpressCOMApp()
|
ooo = Openoffice()
|
||||||
show = ImpressCOMPres(ooo, u'c:/test1.ppt')
|
ooo.createResolver()
|
||||||
show.go()
|
#show = ImpressCOMPres(ooo, u'/home/timali/test1.odp')
|
||||||
show.resume()
|
#show.go()
|
||||||
show.nextStep()
|
#show.resume()
|
||||||
|
#show.nextStep()
|
||||||
|
@ -19,16 +19,21 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, MediaManagerItem
|
from openlp.core.lib import Plugin, MediaManagerItem
|
||||||
from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab
|
from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, Openoffice
|
||||||
|
|
||||||
class PresentationPlugin(Plugin):
|
class PresentationPlugin(Plugin):
|
||||||
|
|
||||||
|
global log
|
||||||
|
log = logging.getLogger(u'PresentationPlugin')
|
||||||
|
|
||||||
def __init__(self, plugin_helpers):
|
def __init__(self, plugin_helpers):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
|
log.debug('Initialised')
|
||||||
Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
|
Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
|
||||||
self.weight = -8
|
self.weight = -8
|
||||||
# Create the plugin icon
|
# Create the plugin icon
|
||||||
@ -44,3 +49,8 @@ class PresentationPlugin(Plugin):
|
|||||||
# Create the MediaManagerItem object
|
# Create the MediaManagerItem object
|
||||||
self.media_item = PresentationMediaItem(self, self.icon, u'Presentations')
|
self.media_item = PresentationMediaItem(self, self.icon, u'Presentations')
|
||||||
return self.media_item
|
return self.media_item
|
||||||
|
|
||||||
|
def check_pre_conditions(self):
|
||||||
|
log.debug('check_pre_conditions')
|
||||||
|
self.openoffice = Openoffice()
|
||||||
|
return self.openoffice.checkOoPid()
|
||||||
|
Loading…
Reference in New Issue
Block a user