Index: gc_lang/fr/oxt/DictOptions/SearchWords.py ================================================================== --- gc_lang/fr/oxt/DictOptions/SearchWords.py +++ gc_lang/fr/oxt/DictOptions/SearchWords.py @@ -3,19 +3,33 @@ # License: MPL 2 import unohelper import uno import traceback +import re import helpers import sw_strings import grammalecte.graphspell as sc import grammalecte.graphspell.ibdawg as ibdawg from com.sun.star.task import XJobExecutor from com.sun.star.awt import XActionListener + +from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK +# BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY +# DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE +from com.sun.star.awt.MessageBoxType import INFOBOX, ERRORBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX + +def MessageBox (xDocument, sMsg, sTitle, nBoxType=INFOBOX, nBoxButtons=BUTTONS_OK): + xParentWin = xDocument.CurrentController.Frame.ContainerWindow + ctx = uno.getComponentContext() + xToolkit = ctx.ServiceManager.createInstanceWithContext("com.sun.star.awt.Toolkit", ctx) + xMsgBox = xToolkit.createMessageBox(xParentWin, nBoxType, nBoxButtons, sTitle, sMsg) + return xMsgBox.execute() + def _waitPointer (funcDecorated): def wrapper (*args, **kwargs): # self is the first parameter if the decorator is applied on a object self = args[0] @@ -188,12 +202,22 @@ @_waitPointer def searchRegex (self): self.initSpellChecker() sFlexPattern = self.xFlexion.Text.strip() sTagsPattern = self.xTags.Text.strip() + try: + if sFlexPattern: + re.compile(sFlexPattern) + except: + MessageBox(self.xDocument, self.dUI.get("regex_error_flexion", "#err"), self.dUI.get("error", "#err"), nBoxType=ERRORBOX) + try: + if sTagsPattern: + re.compile(sTagsPattern) + except: + MessageBox(self.xDocument, self.dUI.get("regex_error_tags", "#err"), self.dUI.get("error", "#err"), nBoxType=ERRORBOX) xGridDataModel = self.xGridModel.GridDataModel xGridDataModel.removeAllRows() for i, aEntry in enumerate(self.oSpellChecker.select(sFlexPattern, sTagsPattern)): xGridDataModel.addRow(i, aEntry) i += 1 if i >= 2000: break Index: gc_lang/fr/oxt/DictOptions/sw_strings.py ================================================================== --- gc_lang/fr/oxt/DictOptions/sw_strings.py +++ gc_lang/fr/oxt/DictOptions/sw_strings.py @@ -22,13 +22,17 @@ "res_flexion": "Flexions", "res_lemma": "Lemmes", "res_tags": "Étiquettes", "close_button": "Fermer", + + "error": "Erreur", + "regex_error_flexion": "L’expression régulière du champ ‹Flexion› est erronée.", + "regex_error_tags": "L’expression régulière du champ ‹Étiquettes› est erronée." }, "en": { "title": "Grammalecte · Search and informations", "close_button": "Close", }, }