From b45f10af8eda21e4b2e9822cb7461206329e1052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 2 Dec 2013 15:29:14 +0100 Subject: [PATCH] add a check for paragraphs filled with nothing but spaces (#3960) --- addon/Tabellio.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addon/Tabellio.py b/addon/Tabellio.py index a3ad49c..0273f2b 100644 --- a/addon/Tabellio.py +++ b/addon/Tabellio.py @@ -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