forked from openlp/openlp
Fixes bug1095699 by rasing an error when the user cancels the codepage selection dialog.
This commit is contained in:
parent
8840df2fb2
commit
635b207fb0
@ -581,7 +581,10 @@ def strip_rtf(text, default_encoding=None):
|
||||
try:
|
||||
encoding, default_encoding = get_encoding(font,
|
||||
font_table, default_encoding, failed=failed)
|
||||
out.append(chr(charcode).decode(encoding))
|
||||
if encoding:
|
||||
out.append(chr(charcode).decode(encoding))
|
||||
else:
|
||||
raise Exception(u'user_canceled')
|
||||
except UnicodeDecodeError:
|
||||
failed = True
|
||||
else:
|
||||
|
@ -180,7 +180,13 @@ class EasyWorshipSongImport(SongImport):
|
||||
self.addAuthor(author_name.strip())
|
||||
if words:
|
||||
# Format the lyrics
|
||||
words, self.encoding = strip_rtf(words, self.encoding)
|
||||
try:
|
||||
words, self.encoding = strip_rtf(words, self.encoding)
|
||||
except Exception as info:
|
||||
if unicode(info) == u'user_canceled':
|
||||
return
|
||||
else:
|
||||
raise
|
||||
verse_type = VerseType.Tags[VerseType.Verse]
|
||||
for verse in SLIDE_BREAK_REGEX.split(words):
|
||||
verse = verse.strip()
|
||||
|
@ -109,8 +109,14 @@ class SongProImport(SongImport):
|
||||
self.finish()
|
||||
return
|
||||
if u'rtf1' in text:
|
||||
text, self.encoding = strip_rtf(text, self.encoding)
|
||||
text = text.rstrip()
|
||||
try:
|
||||
text, self.encoding = strip_rtf(text, self.encoding)
|
||||
text = text.rstrip()
|
||||
except Exception as info:
|
||||
if unicode(info) == u'user_canceled':
|
||||
return
|
||||
else:
|
||||
raise
|
||||
if not text:
|
||||
return
|
||||
if tag == u'A':
|
||||
|
@ -150,8 +150,14 @@ class SundayPlusImport(SongImport):
|
||||
verse_type = HOTKEY_TO_VERSE_TYPE[value]
|
||||
if name == 'rtf':
|
||||
value = self.unescape(value)
|
||||
verse, self.encoding = strip_rtf(value, self.encoding)
|
||||
lines = verse.strip().split('\n')
|
||||
try:
|
||||
verse, self.encoding = strip_rtf(value, self.encoding)
|
||||
lines = verse.strip().split('\n')
|
||||
except Exception as info:
|
||||
if unicode(info) == u'user_canceled':
|
||||
return
|
||||
else:
|
||||
raise
|
||||
# If any line inside any verse contains CCLI or
|
||||
# only Public Domain, we treat this as special data:
|
||||
# we remove that line and add data to specific field.
|
||||
|
Loading…
Reference in New Issue
Block a user