Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -4,11 +4,11 @@ locales = fr_FR fr_BE fr_CA fr_CH fr_LU fr_BF fr_BJ fr_CD fr_CI fr_CM fr_MA fr_ML fr_MU fr_NE fr_RE fr_SN fr_TG country_default = FR name = Grammalecte implname = grammalecte # always use 3 numbers for version: x.y.z -version = 2.0.0 +version = 2.1.0 author = Olivier R. provider = Grammalecte.net link = https://grammalecte.net description = Correcteur grammatical, orthographique et typographique pour le français. extras = README_fr.txt Index: gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py +++ gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py @@ -15,11 +15,11 @@ import grammalecte.graphspell as sc from com.sun.star.awt import XActionListener from com.sun.star.awt.grid import XGridSelectionListener -from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK, BUTTONS_YES_NO_CANCEL +from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK, BUTTONS_YES_NO_CANCEL, BUTTONS_YES_NO # 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, QUERYBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX @@ -141,12 +141,12 @@ self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add')) lColumns = [ {"Title": ui.get("name"), "ColumnWidth": 80}, - {"Title": ui.get("pattern"), "ColumnWidth": 140}, - {"Title": ui.get("repl"), "ColumnWidth": 140}, + {"Title": ui.get("pattern"), "ColumnWidth": 160}, + {"Title": ui.get("repl"), "ColumnWidth": 120}, {"Title": ui.get("regex"), "ColumnWidth": 60}, {"Title": ui.get("casesens"), "ColumnWidth": 60}, ] self.xGridModel = self._addGrid("list_grid", nX, nY1+45, nWidth, 150, lColumns) @@ -175,10 +175,11 @@ self._addWidget('save_and_close', 'Button', self.xDialog.Width-110, self.xDialog.Height-20, 100, 14, Label = ui.get('save_and_close'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) # data self.dRules = {} self.iSelectedRow = -1 + self.nFieldMaxLen = 250 # load configuration self.xGLOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_${implname}/Other/", True) self.loadRules() @@ -290,10 +291,13 @@ MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX) return if not self.xNewName.Text or not self.xNewPattern.Text: MessageBox(self.xDocument, ui.get("name_and_replace_error"), ui.get("name_and_replace_error_title"), ERRORBOX) return + if len(self.xNewPattern.Text) > self.nFieldMaxLen or len(self.xNewRepl.Text) > self.nFieldMaxLen: + MessageBox(self.xDocument, ui.get("max_len_error"), ui.get("max_len_error_title"), ERRORBOX) + return sRuleName = self.xNewName.Text if sRuleName in self.dRules: MessageBox(self.xDocument, ui.get('add_name_error'), ui.get("add_name_error_title"), ERRORBOX) return self.dRules[sRuleName] = { @@ -302,25 +306,29 @@ "bRegex": self.xNewRegex.State == 1, "bCaseSens": self.xNewCaseSens.State == 1 } xGridDataModel = self.xGridModel.GridDataModel xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) + xGridDataModel.sortByColumn(0, True) self._clearAddFields() def _getValuesForRow (self, sRuleName): return (sRuleName, self.dRules[sRuleName]["sPattern"], self.dRules[sRuleName]["sRepl"], str(self.dRules[sRuleName]["bRegex"]), str(self.dRules[sRuleName]["bCaseSens"])) def _checkRuleName (self, sRuleName): - return re.search(r"^\w[\w_#.,;!?-]*$", sRuleName) + return re.search(r"^\w[\w_#.,;!?-]{,14}$", sRuleName) def modifyRule (self): if not self._checkRuleName(self.xEditName.Text): MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX) return sRuleName = self.xEditName.Text if self.iSelectedRow < 0 or not sRuleName or not self.xEditPattern.Text: MessageBox(self.xDocument, ui.get("name_and_replace_error"), ui.get("name_and_replace_error_title"), ERRORBOX) + return + if len(self.xEditPattern.Text) > self.nFieldMaxLen or len(self.xEditRepl.Text) > self.nFieldMaxLen: + MessageBox(self.xDocument, ui.get("max_len_error"), ui.get("max_len_error_title"), ERRORBOX) return if sRuleName != self.sSelectedRuleName and sRuleName in self.dRules: MessageBox(self.xDocument, ui.get("modify_name_error"), ui.get("modify_name_error_title"), ERRORBOX) return try: @@ -349,12 +357,14 @@ del self.dRules[sRuleName] except: traceback.print_exc() def deleteAll (self): - self.dRules.clear() - self.xGridModel.GridDataModel.removeAllRows() + nButton = MessageBox(self.xDocument, ui.get('delete_all_confirm'), ui.get('delete_all'), QUERYBOX, BUTTONS_YES_NO) + if nButton == 2: # ok + self.dRules.clear() + self.xGridModel.GridDataModel.removeAllRows() @_waitPointer def applyRule (self): if self.xEditPattern.Text == "": return @@ -377,10 +387,11 @@ return self.dRules = json.loads(sTFEditorOptions) xGridDataModel = self.xGridModel.GridDataModel for sRuleName in self.dRules: xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) + xGridDataModel.sortByColumn(0, True) except: sMessage = traceback.format_exc() MessageBox(self.xDocument, sMessage, ui.get('error'), ERRORBOX) @_waitPointer @@ -438,10 +449,11 @@ else: # 3 = no for sRuleName, dValues in dImportedRules.items(): if not sRuleName in self.dRules: self.dRules[sRuleName] = dValues xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) + xGridDataModel.sortByColumn(0, True) def exportRules (self): if not self.dRules: return sText = json.dumps(self.dRules, ensure_ascii=False) Index: gc_lang/fr/oxt/TextFormatter/tfe_strings.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/tfe_strings.py +++ gc_lang/fr/oxt/TextFormatter/tfe_strings.py @@ -20,12 +20,12 @@ dStrings = { "fr": { "title": "Grammalecte · Éditeur des transformations personnalisées", "name": "Nom de la règle", - "pattern": "Motif de remplacement", - "repl": "par", + "pattern": "Motif de recherche", + "repl": "remplacer par", "regex": "Regex", "regex_help": "Une expression régulière est une forme de syntaxe décrivant un motif de recherche de caractères", "casesens": "Casse rigide", "casesens_help": "La casse des caractères sera respectée telle quelle.", @@ -42,12 +42,14 @@ "import": "Importer", "export": "Exporter", "delete_all": "Tout supprimer", "save_and_close": "Enregistrer et fermer", - "name_error": "Pour le nom des règles, utilisez uniquement les lettres, les nombres et les caractères parmi ‹_-#.,;!?›.", - "name_error_title": "Le nom de la règle n’est pas conforme.", + "delete_all_confirm": "Voulez-vous réellement tout supprimer ?", + + "name_error": "Pour le nom des règles, utilisez uniquement les lettres, les nombres et les caractères parmi ‹_-#.,;!?›. 15 caractères maximum.", + "name_error_title": "Nom de la règle non conforme.", "name_and_replace_error": "Ni le nom de la règle, ni ce qui doit être remplacé ne peut être vide. Veuillez remplir les champs requis.", "name_and_replace_error_title": "L’un des champs requis est vide", "add_name_error": "Une règle porte déjà ce nom. Veuillez modifier son nom.", @@ -56,10 +58,13 @@ "delete_name_error": "Vous avez modifié le nom de la règle. Veuillez resélectionner la règle que vous voulez supprimer, et cliquez sur ‹Supprimer›.", "delete_name_error_title": "Nom de la règle à supprimer douteux", "modify_name_error": "Une autre règle porte déjà ce nom. Veuillez modifier le nom de la règle.", "modify_name_error_title": "Nouveau nom déjà utilisé par une autre règle", + + "max_len_error": "Le motif de recherche et le texte remplacé ne peuvent dépasser 250 caractères.", + "max_len_error_title": "Champs non conformes", "import_question": "Voulez-vous que les règles importées écrasent celles existantes si elles possèdent un nom identique ?", "import_title": "Importation d’un fichier de règles de transformation", "error": "Erreur", @@ -67,12 +72,12 @@ }, "en": { "title": "Grammalecte · Editor for custom transformations", "name": "Rule name", - "pattern": "Replacement pattern", - "repl": "by", + "pattern": "Search pattern", + "repl": "replace by", "regex": "Regex", "regex_help": "A regular expression is a kind of syntax describing a search pattern of characters", "casesens": "Case sensitivity", "casesens_help": "Characters case will be treated as written.", @@ -89,11 +94,13 @@ "import": "Import", "export": "Export", "delete_all": "Delete all", "save_and_close": "Save and close", - "name_error": "For rules names, only use letters, numbers et characters among ‹_-#.,;!?›", + "delete_all_confirm": "Do you really want to delete all entries?", + + "name_error": "For rules names, only use letters, numbers et characters among ‹_-#.,;!?›. Maximum: 15 characters.", "name_error_title": "Le nom de la règle n’est pas conforme.", "name_and_replace_error": "Neither the rule name, neither what has to be replaced can be empty. Please, fill the required fields.", "name_and_replace_error_title": "One of the required fields is empty", @@ -103,10 +110,13 @@ "delete_name_error": "You have modified the name of the rule. Please, select again the rule you want to delete and click on ‹Delete›.", "delete_name_error_title": "Dubious rule name to delete", "modify_name_error": "This rule name is already used by another rule. Please, modify the rule name.", "modify_name_error_title": "New rule name already used by another rule", + + "max_len_error": "The search pattern and the replacing text can’t exceed 250 characters.", + "max_len_error_title": "Non-compliant fields", "import_question": "Do you want that imported rules replace existing ones if they have the same name?", "import_title": "Importation of a transformation rules file", "error": "Error",