openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #06872
[Merge] lp:~j-corwin/openlp/general into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/general into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
Jon Tibble (meths)
Related bugs:
Bug #634771 in OpenLP: "OpenLP 1.9.2+bzr1016-0ubuntu1~lucid1 does not start"
https://bugs.launchpad.net/openlp/+bug/634771
Bug #646718 in OpenLP: "Songbook, Number will not loaded, Title will not be saved"
https://bugs.launchpad.net/openlp/+bug/646718
For more details, see:
https://code.launchpad.net/~j-corwin/openlp/general/+merge/52985
Songs of Fellowship and Generic Document imports work once again
Also repair auto-insert-chorus-into-verse-order for SoF
--
https://code.launchpad.net/~j-corwin/openlp/general/+merge/52985
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/lib/oooimport.py'
--- openlp/plugins/songs/lib/oooimport.py 2011-02-24 15:54:21 +0000
+++ openlp/plugins/songs/lib/oooimport.py 2011-03-11 09:20:58 +0000
@@ -96,7 +96,7 @@
"""
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 @@
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,9 +134,11 @@
"""
Open the passed file in OpenOffice.org Impress
"""
+ self.filepath = filepath
if os.name == u'nt':
- url = u'file:///' + filepath.replace(u'\\', u'/')
+ url = filepath.replace(u'\\', u'/')
url = url.replace(u':', u'|').replace(u' ', u'%20')
+ url = u'file:///' + url
else:
url = uno.systemPathToFileUrl(filepath)
properties = []
@@ -190,10 +192,7 @@
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()
+ self.process_songs_text(text)
return
def process_doc(self):
@@ -215,6 +214,16 @@
if textportion.BreakType in (PAGE_AFTER, PAGE_BOTH):
paratext += u'\f'
text += paratext + u'\n'
- songs = SongImport.process_songs_text(self.manager, text)
- for song in songs:
- song.finish()
+ self.process_songs_text(text)
+
+ def process_songs_text(self, text):
+ songtexts = self.tidy_text(text).split(u'\f')
+ self.set_defaults()
+ for songtext in songtexts:
+ if songtext.strip():
+ self.process_song_text(songtext.strip())
+ if self.check_complete():
+ self.finish()
+ self.set_defaults()
+ if self.check_complete():
+ self.finish()
=== modified file 'openlp/plugins/songs/lib/sofimport.py'
--- openlp/plugins/songs/lib/sofimport.py 2011-02-24 15:54:21 +0000
+++ openlp/plugins/songs/lib/sofimport.py 2011-03-11 09:20:58 +0000
@@ -72,6 +72,7 @@
to SongImport for writing song to disk
"""
OooImport.__init__(self, manager, **kwargs)
+ self.song = False
def process_ooo_document(self):
"""
@@ -94,8 +95,8 @@
if paragraph.supportsService("com.sun.star.text.Paragraph"):
self.process_paragraph(paragraph)
if self.song:
- self.song.finish()
- self.song = None
+ self.finish()
+ self.song = False
def process_paragraph(self, paragraph):
"""
@@ -143,7 +144,7 @@
self.blanklines += 1
if self.blanklines > 1:
return
- if self.song.title != u'':
+ if self.title != u'':
self.finish_verse()
return
self.blanklines = 0
@@ -161,17 +162,17 @@
self.skip_to_close_bracket = True
return
if text.startswith(u'Copyright'):
- self.song.add_copyright(text)
+ self.add_copyright(text)
return
if text == u'(Repeat)':
self.finish_verse()
- self.song.repeat_verse()
+ self.repeat_verse()
return
- if self.song.title == u'':
- if self.song.copyright == u'':
- self.add_author(text)
+ if self.title == u'':
+ if self.copyright == u'':
+ self.add_sof_author(text)
else:
- self.song.add_copyright(text)
+ self.add_copyright(text)
return
self.add_verse_line(text)
@@ -183,15 +184,15 @@
into line
"""
text = textportion.getString()
- text = SongImport.tidy_text(text)
+ text = self.tidy_text(text)
if text.strip() == u'':
return text
if textportion.CharWeight == BOLD:
boldtext = text.strip()
- if boldtext.isdigit() and self.song.song_number == '':
+ if boldtext.isdigit() and self.song_number == '':
self.add_songnumber(boldtext)
return u''
- if self.song.title == u'':
+ if self.title == u'':
text = self.uncap_text(text)
self.add_title(text)
return text
@@ -207,10 +208,11 @@
"""
if self.song:
self.finish_verse()
- if not self.song.check_complete():
+ if not self.check_complete():
return
- self.song.finish()
- self.song = SongImport(self.manager)
+ self.finish()
+ self.song = True
+ self.set_defaults()
self.skip_to_close_bracket = False
self.is_chorus = False
self.italics = False
@@ -221,17 +223,17 @@
Add a song number, store as alternate title. Also use the song
number to work out which songbook we're in
"""
- self.song.song_number = song_no
- self.song.alternate_title = song_no + u'.'
- self.song.song_book_pub = u'Kingsway Publications'
+ self.song_number = song_no
+ self.alternate_title = song_no + u'.'
+ self.song_book_pub = u'Kingsway Publications'
if int(song_no) <= 640:
- self.song.song_book = u'Songs of Fellowship 1'
+ self.song_book = u'Songs of Fellowship 1'
elif int(song_no) <= 1150:
- self.song.song_book = u'Songs of Fellowship 2'
+ self.song_book = u'Songs of Fellowship 2'
elif int(song_no) <= 1690:
- self.song.song_book = u'Songs of Fellowship 3'
+ self.song_book = u'Songs of Fellowship 3'
else:
- self.song.song_book = u'Songs of Fellowship 4'
+ self.song_book = u'Songs of Fellowship 4'
def add_title(self, text):
"""
@@ -243,10 +245,10 @@
title = title[1:]
if title.endswith(u','):
title = title[:-1]
- self.song.title = title
+ self.title = title
self.import_wizard.incrementProgressBar(u'Processing song ' + title, 0)
- def add_author(self, text):
+ def add_sof_author(self, text):
"""
Add the author. OpenLP stores them individually so split by 'and', '&'
and comma.
@@ -254,7 +256,7 @@
"Mr Smith" and "Mrs Smith".
"""
text = text.replace(u' and ', u' & ')
- self.song.parse_author(text)
+ self.parse_author(text)
def add_verse_line(self, text):
"""
@@ -262,7 +264,7 @@
we're beyond the second line of first verse, then this indicates
a change of verse. Italics are a chorus
"""
- if self.italics != self.is_chorus and ((len(self.song.verses) > 0) or
+ if self.italics != self.is_chorus and ((len(self.verses) > 0) or
(self.currentverse.count(u'\n') > 1)):
self.finish_verse()
if self.italics:
@@ -282,14 +284,14 @@
splitat = None
else:
versetag = u'V'
- splitat = self.verse_splits(self.song.song_number)
+ splitat = self.verse_splits(self.song_number)
if splitat:
ln = 0
verse = u''
for line in self.currentverse.split(u'\n'):
ln += 1
if line == u'' or ln > splitat:
- self.song.add_verse(verse, versetag)
+ self.add_sof_verse(verse, versetag)
ln = 0
if line:
verse = line + u'\n'
@@ -298,12 +300,18 @@
else:
verse += line + u'\n'
if verse:
- self.song.add_verse(verse, versetag)
+ self.add_sof_verse(verse, versetag)
else:
- self.song.add_verse(self.currentverse, versetag)
+ self.add_sof_verse(self.currentverse, versetag)
self.currentverse = u''
self.is_chorus = False
+ def add_sof_verse(self, lyrics, tag):
+ self.add_verse(lyrics, tag)
+ if not self.is_chorus and u'C1' in self.verse_order_list_generated:
+ self.verse_order_list_generated.append(u'C1')
+ self.verse_order_list_generated_useful = True
+
def uncap_text(self, text):
"""
Words in the title are in all capitals, so we lowercase them.
=== modified file 'openlp/plugins/songs/lib/songimport.py'
--- openlp/plugins/songs/lib/songimport.py 2011-03-06 16:28:26 +0000
+++ openlp/plugins/songs/lib/songimport.py 2011-03-11 09:20:58 +0000
@@ -103,23 +103,7 @@
def register(self, import_wizard):
self.import_wizard = import_wizard
- @staticmethod
- def process_songs_text(manager, text):
- songs = []
- songtexts = SongImport.tidy_text(text).split(u'\f')
- song = SongImport(manager)
- for songtext in songtexts:
- if songtext.strip():
- song.process_song_text(songtext.strip())
- if song.check_complete():
- songs.append(song)
- song = SongImport(manager)
- if song.check_complete():
- songs.append(song)
- return songs
-
- @staticmethod
- def tidy_text(text):
+ def tidy_text(self, text):
"""
Get rid of some dodgy unicode and formatting characters we're not
interested in. Some can be converted to ascii.
@@ -146,12 +130,12 @@
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:
@@ -240,7 +224,7 @@
self.verse_counts[verse_def[0]] = int(verse_def[1:])
self.verses.append([verse_def, verse_text.rstrip(), lang])
self.verse_order_list_generated.append(verse_def)
-
+
def repeat_verse(self):
"""
Repeat the previous verse in the verse order
Follow ups