From 292429c6e610d34da774b82bbded9193b217d1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 16 Dec 2013 10:05:06 +0100 Subject: [PATCH] addon: warn when document has multiple prefaces (#4076) --- addon/Tabellio.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addon/Tabellio.py b/addon/Tabellio.py index 0273f2b..d5bac3c 100644 --- a/addon/Tabellio.py +++ b/addon/Tabellio.py @@ -852,6 +852,8 @@ class StructureError: return u'Les parties légistiques doivent démarrer à un niveau supérieur' if self.type == 'preface in wrong place': return u'La préface est placée à un mauvais endroit' + if self.type == 'two prefaces': + return u'Le document contient deux préfaces' if self.type == 'word-copy-paste-horizontal-line': return u'Ligne horizontale, vraisemblablement copié/collé' if self.type == 'paragraph-filled-with-nothing-but-spaces': @@ -869,6 +871,8 @@ class StructureError: return u'''Erreur de hiérarchie légistique. Une partie légistique ne peut démarrer au niveau section ou sous-section. Les choix possibles sont Partie, Livre, Titre ou chapitre.''' if self.type == 'preface in wrong place': return u'''La préface doit se trouver à la base du document ou au niveau "Partie".''' + if self.type == 'two prefaces': + return u'Une seule préface est autorisée dans le document.' if self.type == 'word-copy-paste-horizontal-line': return u'''Une ligne horizontale provient généralement d'un '''\ u'''copié/collé depuis Microsoft Word d'un texte '''\ @@ -1008,6 +1012,7 @@ def check_structure(doc): legistic_styles = ['Lpart', 'LLivre', 'Ltitre', 'Lchapitre', 'Lsection', 'Lsoussection'] paragraph_index = 0 + seen_preface = False while True: error = None currentStyle = cursor.ParaStyleName @@ -1067,6 +1072,9 @@ def check_structure(doc): last_level = styles.index(lastStyle) if last_level > 0: error = StructureError('preface in wrong place') + if seen_preface: + error = StructureError('two prefaces') + seen_preface = True if currentStyle == 'Horizontal Line': # this is added when copy/pasting footnotes from Microsoft Word error = StructureError('word-copy-paste-horizontal-line')