From 0a52af1869cb20bad6eb339c1506e6f7261f93c8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 18:35:11 +0000 Subject: [PATCH] Refactor OOo song imports --- openlp/plugins/songs/lib/oooimport.py | 18 ++++++++++++------ openlp/plugins/songs/lib/sofimport.py | 22 +++++----------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 819a62d1e..32315130a 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -77,18 +77,24 @@ class OooImport(SongImport): if os.path.isfile(filename): self.open_ooo_file(filename) if self.document: - if self.document.supportsService( - "com.sun.star.presentation.PresentationDocument"): - self.process_pres() - if self.document.supportsService( - "com.sun.star.text.TextDocument"): - self.process_doc() + self.process_ooo_document() self.close_ooo_file() self.close_ooo() self.import_wizard.progressBar.setMaximum(1) self.import_wizard.incrementProgressBar(u'', 1) return True + def process_ooo_document(self): + """ + Handle the import process for OpenOffice files. This method facilitates + allowing subclasses to handle specific types of OpenOffice files. + """ + if self.document.supportsService( + "com.sun.star.presentation.PresentationDocument"): + self.process_pres() + if self.document.supportsService("com.sun.star.text.TextDocument"): + self.process_doc() + def start_ooo(self): """ Start OpenOffice.org process diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 82b89141f..96a514f85 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -75,23 +75,11 @@ class SofImport(OooImport): """ OooImport.__init__(self, master_manager, **kwargs) - def do_import(self): - self.stop_import_flag = False - self.start_ooo() - for filename in self.filenames: - if self.stop_import_flag: - self.import_wizard.incrementProgressBar(u'Import cancelled', 0) - return - filename = unicode(filename) - if os.path.isfile(filename): - self.open_ooo_file(filename) - if self.document: - self.process_sof_file() - self.close_ooo_file() - self.close_ooo() - self.import_wizard.progressBar.setMaximum(1) - self.import_wizard.incrementProgressBar(u'', 1) - return True + def process_ooo_document(self): + """ + Handle the import process for SoF files. + """ + self.process_sof_file() def process_sof_file(self): """