Refactor OOo song imports

This commit is contained in:
Jon Tibble 2011-01-26 18:35:11 +00:00
parent 934d26bd0a
commit 0a52af1869
2 changed files with 17 additions and 23 deletions

View File

@ -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

View File

@ -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):
"""