#! /usr/bin/env python # -*- coding: utf-8 -*- import sys legi_styles = [('Titre Préface', 'TitrePreface'), ('Titre Résumé', 'TitreSynthese'), ('Partie', 'Partie'), ('Chap', 'Chap'), ('Sec 1', 'Sec 1'), ('Sec 1.1', 'Sec 1.1'), ('Sec 1.1.1', 'Sec 1.1.1'), ('Sec 1.1.1.1', 'Sec 1.1.1.1'), ('Ss-Titre', 'Sous-Titre'), ('Literal', 'Standard'), ('Note', 'Note'), ('NoteTdM', 'NoteTableDesMatieres'), ('Para', 'Text body') ] legistic_styles = [ ('LPart', 'Lpart'), ('LLivre', 'LLivre'), ('LTitre', 'Ltitre'), ('LChapitre', 'Lchapitre'), ('LSection', 'Lsection'), ('LSous-Section', 'LSous-Section'), ('LArt', 'Larttitre') ] f = sys.stdin.read() def get_xml(styles): s = [] for i, style in enumerate(styles): c = i if styles is legistic_styles: c += len(legi_styles) + 2 stylelabel, stylename = style s.append(''' service:org.entrouvert.openoffice.StyleApply?%(stylename)s %(stylelabel)s _self com.sun.star.text.TextDocument ''' % locals()) return '\n'.join(s) print f.replace( '@TOOLBAR_LEGI_STYLES@', get_xml(legi_styles)).replace( '@TOOLBAR_LEGISTIC_STYLES@', get_xml(legistic_styles))