Index: gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py +++ gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py @@ -4,10 +4,11 @@ import unohelper import uno import traceback import platform +import urllib.parse import os import json import re import helpers @@ -389,14 +390,15 @@ xChild = self.xGLOptionNode.getByName("o_${lang}") 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) + if self.dRules: + 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 @@ -425,10 +427,11 @@ lFile = xFilePicker.getFiles() #print(lFile) spfImported = lFile[0][5:].lstrip("/") # remove file:// if platform.system() != "Windows": spfImported = "/" + spfImported + spfImported = urllib.parse.unquote(spfImported) except: sMessage = traceback.format_exc() MessageBox(self.xDocument, sMessage, ui.get('error'), ERRORBOX) return if not spfImported or not os.path.isfile(spfImported): @@ -474,11 +477,14 @@ # lFile = xFilePicker.getSelectedFiles() lFile = xFilePicker.getFiles() spfExported = lFile[0][5:].lstrip("/") # remove file:// if platform.system() != "Windows": spfExported = "/" + spfExported + spfExported = urllib.parse.unquote(spfExported) + if not spfExported.endswith((".json", ".JSON")): + spfExported += ".json" #spfExported = os.path.join(os.path.expanduser("~"), "fr.personal.json") with open(spfExported, "w", encoding="utf-8") as hDst: hDst.write(sText) except: sMessage = traceback.format_exc() MessageBox(self.xDocument, sMessage, ui.get('error'), ERRORBOX)