Overview
Comment: | [lo] text formatter editor update |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | lo |
Files: | files | file ages | folders |
SHA3-256: |
7d2246bb86b0f8e57dafac338d778df0 |
User & Date: | olr on 2020-12-18 09:59:47 |
Other Links: | manifest | tags |
Context
2020-12-18
| ||
10:31 | [lo] text formatter editor: small ui update check-in: d7ab6f010f user: olr tags: trunk, lo | |
09:59 | [lo] text formatter editor update check-in: 7d2246bb86 user: olr tags: trunk, lo | |
2020-12-17
| ||
20:31 | [lo] code cleaning & clarification check-in: 130814503c user: olr tags: trunk, lo | |
Changes
Modified gc_lang/fr/config.ini from [9d8deb0cf0] to [ac5fc1a082].
1 2 3 4 5 6 7 8 | [args] lang = fr lang_name = French 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 | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [args] lang = fr lang_name = French 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.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 logo = logo.png |
︙ | ︙ |
Modified gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py from [5fe2011618] to [8b8fa9d3c8].
︙ | ︙ | |||
13 14 15 16 17 18 19 | import helpers import tfe_strings as ui import grammalecte.graphspell as sc from com.sun.star.awt import XActionListener from com.sun.star.awt.grid import XGridSelectionListener | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import helpers import tfe_strings as ui 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, 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 def MessageBox (xDocument, sMsg, sTitle, nBoxType=INFOBOX, nBoxButtons=BUTTONS_OK): xParentWin = xDocument.CurrentController.Frame.ContainerWindow |
︙ | ︙ | |||
139 140 141 142 143 144 145 | self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help")) self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True) self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add')) lColumns = [ {"Title": ui.get("name"), "ColumnWidth": 80}, | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help")) self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True) 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": 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) # Modify self._addWidget("edit_entry", 'FixedLine', nX, nY2, nWidth, nHeight, Label = ui.get("edit_entry"), FontDescriptor = xFDTitle) |
︙ | ︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 185 186 | self._addWidget('export', 'Button', nX+55, self.xDialog.Height-20, 50, 14, Label = ui.get('export'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) self._addWidget('delete_all', 'Button', nX + (self.xDialog.Width/2)-35, self.xDialog.Height-20, 70, 14, Label = ui.get('delete_all'), FontDescriptor = xFDTitle, TextColor = 0xAA0000) 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 # load configuration self.xGLOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_${implname}/Other/", True) self.loadRules() # container self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx) | > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | self._addWidget('export', 'Button', nX+55, self.xDialog.Height-20, 50, 14, Label = ui.get('export'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) self._addWidget('delete_all', 'Button', nX + (self.xDialog.Width/2)-35, self.xDialog.Height-20, 70, 14, Label = ui.get('delete_all'), FontDescriptor = xFDTitle, TextColor = 0xAA0000) 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() # container self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx) |
︙ | ︙ | |||
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | def addRule (self): if not self._checkRuleName(self.xNewName.Text): 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 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] = { "sPattern": self.xNewPattern.Text, "sRepl": self.xNewRepl.Text, "bRegex": self.xNewRegex.State == 1, "bCaseSens": self.xNewCaseSens.State == 1 } xGridDataModel = self.xGridModel.GridDataModel xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) 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): | > > > > | > > > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | def addRule (self): if not self._checkRuleName(self.xNewName.Text): 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] = { "sPattern": self.xNewPattern.Text, "sRepl": self.xNewRepl.Text, "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_#.,;!?-]{,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: self.dRules[sRuleName] = { "sPattern": self.xEditPattern.Text, |
︙ | ︙ | |||
347 348 349 350 351 352 353 | self.xGridModel.GridDataModel.removeRow(self.iSelectedRow) self.iSelectedRow = -1 del self.dRules[sRuleName] except: traceback.print_exc() def deleteAll (self): | > > | | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | self.xGridModel.GridDataModel.removeRow(self.iSelectedRow) self.iSelectedRow = -1 del self.dRules[sRuleName] except: traceback.print_exc() def deleteAll (self): 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 try: xRD = self.xDocument.createReplaceDescriptor() |
︙ | ︙ | |||
375 376 377 378 379 380 381 382 383 384 385 386 387 388 | sTFEditorOptions = xChild.getPropertyValue("tfe_rules") if not sTFEditorOptions: return self.dRules = json.loads(sTFEditorOptions) xGridDataModel = self.xGridModel.GridDataModel for sRuleName in self.dRules: xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) except: sMessage = traceback.format_exc() MessageBox(self.xDocument, sMessage, ui.get('error'), ERRORBOX) @_waitPointer def saveRules (self): try: | > | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | sTFEditorOptions = xChild.getPropertyValue("tfe_rules") if not sTFEditorOptions: 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 def saveRules (self): try: |
︙ | ︙ | |||
436 437 438 439 440 441 442 443 444 445 446 447 448 449 | for sRuleName in self.dRules: xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) 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)) def exportRules (self): if not self.dRules: return sText = json.dumps(self.dRules, ensure_ascii=False) try: xFilePicker = self.xSvMgr.createInstanceWithContext('com.sun.star.ui.dialogs.FilePicker', self.ctx) # other possibility: com.sun.star.ui.dialogs.SystemFilePicker | > | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | for sRuleName in self.dRules: xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) 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) try: xFilePicker = self.xSvMgr.createInstanceWithContext('com.sun.star.ui.dialogs.FilePicker', self.ctx) # other possibility: com.sun.star.ui.dialogs.SystemFilePicker |
︙ | ︙ |
Modified gc_lang/fr/oxt/TextFormatter/tfe_strings.py from [cec8754aec] to [10a90636db].
︙ | ︙ | |||
18 19 20 21 22 23 24 | dStrings = { "fr": { "title": "Grammalecte · Éditeur des transformations personnalisées", "name": "Nom de la règle", | | | > > | | > > > | | > > | > > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | dStrings = { "fr": { "title": "Grammalecte · Éditeur des transformations personnalisées", "name": "Nom de la règle", "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.", "new_entry": "Nouvelle entrée", "edit_entry": "Entrée sélectionnée", "add": "Ajouter", "delete": "Supprimer", "modify": "Modifier", "apply": "Appliquer", "apply_help": "Appliquer cette règle sur le texte", "modif": "modifications", "import": "Importer", "export": "Exporter", "delete_all": "Tout supprimer", "save_and_close": "Enregistrer et fermer", "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.", "add_name_error_title": "Nom déjà utilisé", "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", "file_not_found": "Fichier introuvable : ", }, "en": { "title": "Grammalecte · Editor for custom transformations", "name": "Rule name", "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.", "new_entry": "New entry", "edit_entry": "Selected entry", "add": "Add", "delete": "Delete", "modify": "Modify", "apply": "Apply", "apply_help": "Apply this rule on the text", "modif": "modifications", "import": "Import", "export": "Export", "delete_all": "Delete all", "save_and_close": "Save and close", "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", "add_name_error": "There is already a rule with this name. Please, find another name.", "add_name_error_title": "Rule name already used", "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", "file_not_found": "File not found: ", } } |