From b522247094b1a1af3dceed56fe830f323082a450 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 10 Mar 2011 22:25:58 +0000 Subject: [PATCH] Fix SoF/OOo imports --- openlp/plugins/songs/lib/oooimport.py | 10 +++++----- openlp/plugins/songs/lib/songimport.py | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 4fb6b5876..77b629398 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -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() diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index fc78b5033..78d203ae3 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -55,13 +55,14 @@ class SongImport(QtCore.QObject): """ self.manager = manager QtCore.QObject.__init__(self) - if kwargs.has_key(u'filename'): - self.import_source = kwargs[u'filename'] - elif kwargs.has_key(u'filenames'): - self.import_source = kwargs[u'filenames'] - else: - raise KeyError(u'Keyword arguments "filename[s]" not supplied.') - log.debug(self.import_source) + if kwargs: + if kwargs.has_key(u'filename'): + self.import_source = kwargs[u'filename'] + elif kwargs.has_key(u'filenames'): + self.import_source = kwargs[u'filenames'] + else: + raise KeyError(u'Keyword arguments "filename[s]" not supplied.') + log.debug(self.import_source) self.song = None self.stop_import_flag = False self.set_defaults() @@ -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: