Fix SoF/OOo imports

This commit is contained in:
Jonathan Corwin 2011-03-10 22:25:58 +00:00
parent 31d2ca5a2b
commit b522247094
2 changed files with 15 additions and 14 deletions

View File

@ -96,7 +96,7 @@ class OooImport(SongImport):
"""
if os.name == u'nt':
self.start_ooo_process()
self.desktop = self.manager.createInstance(
self.desktop = self.ooo_manager.createInstance(
u'com.sun.star.frame.Desktop')
else:
context = uno.getComponentContext()
@ -118,9 +118,9 @@ class OooImport(SongImport):
def start_ooo_process(self):
try:
if os.name == u'nt':
self.manager = Dispatch(u'com.sun.star.ServiceManager')
self.manager._FlagAsMethod(u'Bridge_GetStruct')
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
self.ooo_manager = Dispatch(u'com.sun.star.ServiceManager')
self.ooo_manager._FlagAsMethod(u'Bridge_GetStruct')
self.ooo_manager._FlagAsMethod(u'Bridge_GetValueObject')
else:
cmd = get_uno_command()
process = QtCore.QProcess()
@ -134,6 +134,7 @@ class OooImport(SongImport):
"""
Open the passed file in OpenOffice.org Impress
"""
self.filepath = filepath
if os.name == u'nt':
url = filepath.replace(u'\\', u'/')
url = url.replace(u':', u'|').replace(u' ', u'%20')
@ -191,7 +192,6 @@ class OooImport(SongImport):
if slidetext.strip() == u'':
slidetext = u'\f'
text += slidetext
song = SongImport(self.manager)
songs = SongImport.process_songs_text(self.manager, text)
for song in songs:
song.finish()

View File

@ -55,6 +55,7 @@ class SongImport(QtCore.QObject):
"""
self.manager = manager
QtCore.QObject.__init__(self)
if kwargs:
if kwargs.has_key(u'filename'):
self.import_source = kwargs[u'filename']
elif kwargs.has_key(u'filenames'):
@ -146,12 +147,12 @@ class SongImport(QtCore.QObject):
def process_verse_text(self, text):
lines = text.split(u'\n')
if text.lower().find(self.copyright_string) >= 0 \
or text.find(SongStrings.CopyrightSymbol) >= 0:
or text.find(unicode(SongStrings.CopyrightSymbol)) >= 0:
copyright_found = False
for line in lines:
if (copyright_found or
line.lower().find(self.copyright_string) >= 0 or
line.find(SongStrings.CopyrightSymbol) >= 0):
line.find(unicode(SongStrings.CopyrightSymbol)) >= 0):
copyright_found = True
self.add_copyright(line)
else: