add a check for paragraphs filled with nothing but spaces (#3960)

This commit is contained in:
Frédéric Péters 2013-12-02 15:29:14 +01:00
parent a9d8cd5412
commit b45f10af8e
1 changed files with 9 additions and 0 deletions

View File

@ -854,6 +854,8 @@ class StructureError:
return u'La préface est placée à un mauvais endroit'
if self.type == 'word-copy-paste-horizontal-line':
return u'Ligne horizontale, vraisemblablement copié/collé'
if self.type == 'paragraph-filled-with-nothing-but-spaces':
return u'Paragraphe composé uniquement d\'espaces'
def get_long(self):
'''Get a longer description of the error'''
@ -871,6 +873,8 @@ class StructureError:
return u'''Une ligne horizontale provient généralement d'un '''\
u'''copié/collé depuis Microsoft Word d'un texte '''\
u'''contenant une note de bas de page.'''
if self.type == 'paragraph-filled-with-nothing-but-spaces':
return u'Paragraphe composé uniquement d\'espaces'
class StructureCheckListListener(unohelper.Base, XItemListener):
@ -1072,6 +1076,11 @@ def check_structure(doc):
seenContent = True
seenLegiContent = True
cursor.gotoEndOfParagraph(True)
s = cursor.String.replace(' ', '').replace('\t', '').replace(u'\xa0', '')
if cursor.String and s == '': # paragraph filled with nothing but spaces
error = StructureError('paragraph-filled-with-nothing-but-spaces')
if error:
view_cursor.gotoRange(cursor, False)
error.paragraph_index = paragraph_index