From 554ea7ebb1304429edbe0ab112119389a0024a4f Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Thu, 18 Jan 2024 19:49:19 +0100 Subject: [PATCH] MaskEdit property editor: refactor loading EditMask Sample files and displaying them in he listbox. - support Delhpi .dem files - support new Lazarus .lem files (with a more forgiving syntax) - minimize the calls to the parse function for sample files --- .../ideintf/languages/objinspstrconsts.ca.po | 9 + .../ideintf/languages/objinspstrconsts.cs.po | 9 + .../ideintf/languages/objinspstrconsts.de.po | 9 + .../ideintf/languages/objinspstrconsts.es.po | 9 + .../ideintf/languages/objinspstrconsts.fi.po | 9 + .../ideintf/languages/objinspstrconsts.fr.po | 9 + .../ideintf/languages/objinspstrconsts.he.po | 9 + .../ideintf/languages/objinspstrconsts.hu.po | 9 + .../ideintf/languages/objinspstrconsts.id.po | 9 + .../ideintf/languages/objinspstrconsts.it.po | 9 + .../ideintf/languages/objinspstrconsts.ja.po | 9 + .../ideintf/languages/objinspstrconsts.lt.po | 9 + .../ideintf/languages/objinspstrconsts.nl.po | 9 + .../ideintf/languages/objinspstrconsts.pl.po | 9 + .../ideintf/languages/objinspstrconsts.pot | 9 + .../languages/objinspstrconsts.pt_BR.po | 9 + .../ideintf/languages/objinspstrconsts.ru.po | 9 + .../ideintf/languages/objinspstrconsts.sk.po | 9 + .../ideintf/languages/objinspstrconsts.tr.po | 9 + .../ideintf/languages/objinspstrconsts.uk.po | 9 + .../languages/objinspstrconsts.zh_CN.po | 9 + components/ideintf/maskpropedit.pas | 243 ++++++++++++++---- components/ideintf/objinspstrconsts.pas | 3 + 23 files changed, 382 insertions(+), 53 deletions(-) diff --git a/components/ideintf/languages/objinspstrconsts.ca.po b/components/ideintf/languages/objinspstrconsts.ca.po index 8e5b5803ad..fef08302bb 100644 --- a/components/ideintf/languages/objinspstrconsts.ca.po +++ b/components/ideintf/languages/objinspstrconsts.ca.po @@ -619,6 +619,11 @@ msgstr "S'ha produït un error mentre es carregava l'imatge" msgid "Error loading image \"%s\":%s%s" msgstr "S'ha produït un error mentre es carregava l'imatge %s%s%s:%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -724,6 +729,10 @@ msgstr "" msgid "Masks ..." msgstr "" +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Mètode" diff --git a/components/ideintf/languages/objinspstrconsts.cs.po b/components/ideintf/languages/objinspstrconsts.cs.po index adc4c9bd15..1c1a64689a 100644 --- a/components/ideintf/languages/objinspstrconsts.cs.po +++ b/components/ideintf/languages/objinspstrconsts.cs.po @@ -596,6 +596,11 @@ msgstr "Chyba načítání obrázku" msgid "Error loading image \"%s\":%s%s" msgstr "Chyba načítání souboru \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -702,6 +707,10 @@ msgstr "Načíst obrázek" msgid "Masks ..." msgstr "Masky ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metoda" diff --git a/components/ideintf/languages/objinspstrconsts.de.po b/components/ideintf/languages/objinspstrconsts.de.po index 2940b3cac0..6eea63ab4c 100644 --- a/components/ideintf/languages/objinspstrconsts.de.po +++ b/components/ideintf/languages/objinspstrconsts.de.po @@ -595,6 +595,11 @@ msgstr "Fehler beim Laden des Bilds" msgid "Error loading image \"%s\":%s%s" msgstr "Fehler beim Laden des Bilds \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -700,6 +705,10 @@ msgstr "Bild laden" msgid "Masks ..." msgstr "Masken..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Methode" diff --git a/components/ideintf/languages/objinspstrconsts.es.po b/components/ideintf/languages/objinspstrconsts.es.po index 0241546fed..e2b6378c7c 100644 --- a/components/ideintf/languages/objinspstrconsts.es.po +++ b/components/ideintf/languages/objinspstrconsts.es.po @@ -598,6 +598,11 @@ msgstr "Error cargando imagen" msgid "Error loading image \"%s\":%s%s" msgstr "Error cargando imagen \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -703,6 +708,10 @@ msgstr "Cargar dibujo" msgid "Masks ..." msgstr "Máscaras..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Método" diff --git a/components/ideintf/languages/objinspstrconsts.fi.po b/components/ideintf/languages/objinspstrconsts.fi.po index 8faccf26f3..17afb1fe8d 100644 --- a/components/ideintf/languages/objinspstrconsts.fi.po +++ b/components/ideintf/languages/objinspstrconsts.fi.po @@ -589,6 +589,11 @@ msgstr "Virhe kuvaa ladattaessa" msgid "Error loading image \"%s\":%s%s" msgstr "Virhe ladattaessa kuvaa \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -694,6 +699,10 @@ msgstr "Tuo kuva" msgid "Masks ..." msgstr "Maskit ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metodi" diff --git a/components/ideintf/languages/objinspstrconsts.fr.po b/components/ideintf/languages/objinspstrconsts.fr.po index e6eda721ef..648921b071 100644 --- a/components/ideintf/languages/objinspstrconsts.fr.po +++ b/components/ideintf/languages/objinspstrconsts.fr.po @@ -593,6 +593,11 @@ msgstr "Erreur au chargement de l'image" msgid "Error loading image \"%s\":%s%s" msgstr "Erreur au chargement de l'image \"%s\" :%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -698,6 +703,10 @@ msgstr "Charger une image" msgid "Masks ..." msgstr "Masques..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Méthode" diff --git a/components/ideintf/languages/objinspstrconsts.he.po b/components/ideintf/languages/objinspstrconsts.he.po index 65c800c73d..8d37eb1f97 100644 --- a/components/ideintf/languages/objinspstrconsts.he.po +++ b/components/ideintf/languages/objinspstrconsts.he.po @@ -616,6 +616,11 @@ msgstr "שגיאה בעריכת דמות" msgid "Error loading image \"%s\":%s%s" msgstr "שגיאה בטעינת דמות %s%s%s:%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -726,6 +731,10 @@ msgstr "טען תמונה" msgid "Masks ..." msgstr "מסכות ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "מתודה" diff --git a/components/ideintf/languages/objinspstrconsts.hu.po b/components/ideintf/languages/objinspstrconsts.hu.po index 9e6752e025..9b4abfb69d 100644 --- a/components/ideintf/languages/objinspstrconsts.hu.po +++ b/components/ideintf/languages/objinspstrconsts.hu.po @@ -596,6 +596,11 @@ msgstr "Hiba kép betöltése közben" msgid "Error loading image \"%s\":%s%s" msgstr "Hiba a(z) \"%s\" kép betöltése közben:%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -701,6 +706,10 @@ msgstr "Kép betöltése" msgid "Masks ..." msgstr "Maszkok ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metódus" diff --git a/components/ideintf/languages/objinspstrconsts.id.po b/components/ideintf/languages/objinspstrconsts.id.po index 3c9ad9190c..0a50433969 100644 --- a/components/ideintf/languages/objinspstrconsts.id.po +++ b/components/ideintf/languages/objinspstrconsts.id.po @@ -619,6 +619,11 @@ msgstr "Kesalahan pengambilan gambar" msgid "Error loading image \"%s\":%s%s" msgstr "Kesalahan pengambilan gambar %s%s%s:%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -726,6 +731,10 @@ msgstr "Ambil gambar" msgid "Masks ..." msgstr "Masks..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metode" diff --git a/components/ideintf/languages/objinspstrconsts.it.po b/components/ideintf/languages/objinspstrconsts.it.po index 9252c64716..afd603e185 100644 --- a/components/ideintf/languages/objinspstrconsts.it.po +++ b/components/ideintf/languages/objinspstrconsts.it.po @@ -599,6 +599,11 @@ msgstr "Errore nel caricamento dell'immagine" msgid "Error loading image \"%s\":%s%s" msgstr "Errore nel caricamento dell'immagine \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -704,6 +709,10 @@ msgstr "Carica Immagine" msgid "Masks ..." msgstr "Maschere..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metodo" diff --git a/components/ideintf/languages/objinspstrconsts.ja.po b/components/ideintf/languages/objinspstrconsts.ja.po index 7ae6b14dcb..be2e39f281 100644 --- a/components/ideintf/languages/objinspstrconsts.ja.po +++ b/components/ideintf/languages/objinspstrconsts.ja.po @@ -599,6 +599,11 @@ msgstr "イメージの読み込み中にエラー" msgid "Error loading image \"%s\":%s%s" msgstr "イメージの読み込み中にエラー %s%s%s:%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -705,6 +710,10 @@ msgstr "画像の読み込み" msgid "Masks ..." msgstr "マスク ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "メソッド" diff --git a/components/ideintf/languages/objinspstrconsts.lt.po b/components/ideintf/languages/objinspstrconsts.lt.po index 5d4c00787e..e74db8c98d 100644 --- a/components/ideintf/languages/objinspstrconsts.lt.po +++ b/components/ideintf/languages/objinspstrconsts.lt.po @@ -597,6 +597,11 @@ msgstr "Klaida įkeliant paveikslą" msgid "Error loading image \"%s\":%s%s" msgstr "Įkeliant paveikslą įvyko klaida „%s“:%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -702,6 +707,10 @@ msgstr "Įkelti paveikslą" msgid "Masks ..." msgstr "Kaukės…" +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metodas" diff --git a/components/ideintf/languages/objinspstrconsts.nl.po b/components/ideintf/languages/objinspstrconsts.nl.po index 0abe62fd9c..fb61366fe2 100644 --- a/components/ideintf/languages/objinspstrconsts.nl.po +++ b/components/ideintf/languages/objinspstrconsts.nl.po @@ -608,6 +608,11 @@ msgstr "Fout bij het laden van het plaatje" msgid "Error loading image \"%s\":%s%s" msgstr "Fout bij het laden van plaatje \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -715,6 +720,10 @@ msgstr "Laad plaatje" msgid "Masks ..." msgstr "Maskers..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Methode" diff --git a/components/ideintf/languages/objinspstrconsts.pl.po b/components/ideintf/languages/objinspstrconsts.pl.po index 8b08ea1756..b74f802c2d 100644 --- a/components/ideintf/languages/objinspstrconsts.pl.po +++ b/components/ideintf/languages/objinspstrconsts.pl.po @@ -591,6 +591,11 @@ msgstr "Błąd ładowania obrazu" msgid "Error loading image \"%s\":%s%s" msgstr "Błąd ładowania obrazu \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -696,6 +701,10 @@ msgstr "Wczytaj obraz" msgid "Masks ..." msgstr "Maski..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "" diff --git a/components/ideintf/languages/objinspstrconsts.pot b/components/ideintf/languages/objinspstrconsts.pot index 5053d4d719..45c6873f6e 100644 --- a/components/ideintf/languages/objinspstrconsts.pot +++ b/components/ideintf/languages/objinspstrconsts.pot @@ -583,6 +583,11 @@ msgstr "" msgid "Error loading image \"%s\":%s%s" msgstr "" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -688,6 +693,10 @@ msgstr "" msgid "Masks ..." msgstr "" +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "" diff --git a/components/ideintf/languages/objinspstrconsts.pt_BR.po b/components/ideintf/languages/objinspstrconsts.pt_BR.po index b32c649ba9..ddb3556afa 100644 --- a/components/ideintf/languages/objinspstrconsts.pt_BR.po +++ b/components/ideintf/languages/objinspstrconsts.pt_BR.po @@ -592,6 +592,11 @@ msgstr "Erro ao carregar imagem" msgid "Error loading image \"%s\":%s%s" msgstr "Erro carregando imagem \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -697,6 +702,10 @@ msgstr "Carregar figura" msgid "Masks ..." msgstr "Máscaras ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Método" diff --git a/components/ideintf/languages/objinspstrconsts.ru.po b/components/ideintf/languages/objinspstrconsts.ru.po index fc378f3698..6e2e9cf6d8 100644 --- a/components/ideintf/languages/objinspstrconsts.ru.po +++ b/components/ideintf/languages/objinspstrconsts.ru.po @@ -592,6 +592,11 @@ msgstr "Ошибка загрузки изображения" msgid "Error loading image \"%s\":%s%s" msgstr "Ошибка загрузки изображения \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -697,6 +702,10 @@ msgstr "Загрузить изображение" msgid "Masks ..." msgstr "Маски ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Метод" diff --git a/components/ideintf/languages/objinspstrconsts.sk.po b/components/ideintf/languages/objinspstrconsts.sk.po index 8d44d61b14..e84d178729 100644 --- a/components/ideintf/languages/objinspstrconsts.sk.po +++ b/components/ideintf/languages/objinspstrconsts.sk.po @@ -601,6 +601,11 @@ msgstr "Chyba pri načítaní obrázka" msgid "Error loading image \"%s\":%s%s" msgstr "Chyba pri načítaní obrázka \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -706,6 +711,10 @@ msgstr "Načítať obrázok" msgid "Masks ..." msgstr "Masky..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Metóda" diff --git a/components/ideintf/languages/objinspstrconsts.tr.po b/components/ideintf/languages/objinspstrconsts.tr.po index 32daf4d6fb..884ea8f16e 100644 --- a/components/ideintf/languages/objinspstrconsts.tr.po +++ b/components/ideintf/languages/objinspstrconsts.tr.po @@ -592,6 +592,11 @@ msgstr "Resim yüklenirken hata oluştu" msgid "Error loading image \"%s\":%s%s" msgstr "Resim yüklenirken hata oluştu \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -697,6 +702,10 @@ msgstr "Resim yükle" msgid "Masks ..." msgstr "Maske...." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Yöntem" diff --git a/components/ideintf/languages/objinspstrconsts.uk.po b/components/ideintf/languages/objinspstrconsts.uk.po index 3d35304341..6309363428 100644 --- a/components/ideintf/languages/objinspstrconsts.uk.po +++ b/components/ideintf/languages/objinspstrconsts.uk.po @@ -595,6 +595,11 @@ msgstr "Помилка завантаження зображення" msgid "Error loading image \"%s\":%s%s" msgstr "Помилка завантаження зображення \"%s\":%s%s" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -700,6 +705,10 @@ msgstr "Завантажити зображення" msgid "Masks ..." msgstr "Маски ..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "Метод" diff --git a/components/ideintf/languages/objinspstrconsts.zh_CN.po b/components/ideintf/languages/objinspstrconsts.zh_CN.po index 5fb9c87b02..d5581f97aa 100644 --- a/components/ideintf/languages/objinspstrconsts.zh_CN.po +++ b/components/ideintf/languages/objinspstrconsts.zh_CN.po @@ -593,6 +593,11 @@ msgstr "加载图片错误" msgid "Error loading image \"%s\":%s%s" msgstr "加载图片\"%s\":%s%s错误" +#: objinspstrconsts.oiserrorreadingsamplefile +#, object-pascal-format +msgid "Error reading file %s" +msgstr "" + #: objinspstrconsts.oiserrorwhiledeletingaction #, object-pascal-format msgid "Error while deleting action:%s%s" @@ -698,6 +703,10 @@ msgstr "加载图片" msgid "Masks ..." msgstr "掩码..." +#: objinspstrconsts.oismasksamplefilter +msgid "EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)" +msgstr "" + #: objinspstrconsts.oismethod msgid "Method" msgstr "方法" diff --git a/components/ideintf/maskpropedit.pas b/components/ideintf/maskpropedit.pas index ca3360ee00..f9cf305151 100644 --- a/components/ideintf/maskpropedit.pas +++ b/components/ideintf/maskpropedit.pas @@ -31,6 +31,13 @@ type { TMaskEditorForm } TMaskEditorForm = class(TForm) + private + type + TParsedSample = record + Caption, Example, FormattedExample, Mask: String; + end; + TParsedSamples = array of TParsedSample; + published ButtonPanel1: TButtonPanel; EnableSetsCheckBox: TCheckBox; LoadSampleMasksButton: TButton; @@ -57,8 +64,13 @@ type procedure MaskEditorFormCreate(Sender: TObject); private FEnableSets: Boolean; + ParsedSamples: TParsedSamples; function ConstructEditmask: String; function GetEditMask: string; + function MaskDoFormatText(const EditMask: string; const Value: string; EnableSets: Boolean): String; + function ParseMaskLineDelphi(Line: String; EnableSets: Boolean; out aCaption, aExample, aFormattedExample, aMask: String): Boolean; + function ParseMaskLineLazarus(Line: String; EnableSets: Boolean; out aCaption, aExample, aFormattedExample, aMask: String): Boolean; + procedure LoadAndCleanSampleFile(Fn: String; EnableSets: Boolean; List: TStrings; out AParsedSamples: TParsedSamples); //out list of record? procedure LoadDEMFile(AFileName: string); procedure ReConstructEditmask; procedure SetEditMask(AValue: string); @@ -94,46 +106,6 @@ implementation {$R *.lfm} -procedure ParseMaskLine(Line: String; out Caption, Example, Mask: String); -begin - // in delphi .dem files every mask line contains: - // mask name|mask example|mask - - // 1. Extract caption from Line - Caption := Copy(Line, 1, Pos(' | ', Line) - 1); - Delete(Line, 1, Length(Caption) + 3); - - // 2. Extract example from Line - Example := Copy(Line, 1, Pos(' | ', Line) - 1); - Delete(Line, 1, Length(Example) + 3); - - // 3. Copy what we have to Mask - Mask := Line; -end; - -function MaskDoFormatText(const EditMask: string; const Value: string; EnableSets: Boolean): String; -var - P: Integer; - S: String; -begin - // cheat maskutils while it has no its own MaskDoFormatText - S := EditMask; - P := LastDelimiter(';', S); - if P <> 0 then - begin - S[P + 1] := #32; - dec(P); - while (P > 0) and (S[P] <> ';') do - dec(P); - if P <> 0 then - S[P + 1] := '0'; - end; - try - Result := FormatMaskText(S, Value, EnableSets); - except - Result := Value; - end; -end; { TMaskEditorForm } @@ -150,6 +122,7 @@ begin TestInputLabel.Caption := oisTestInput; EnableSetsCheckBox.Hint := oisEnableSetsHint; + OpenDialog1.Filter := oisMaskSampleFilter; if LazarusIDE<>nil then aDemFile:=LazarusIDE.GetPrimaryConfigPath @@ -185,7 +158,6 @@ var OldTextStyle: TTextStyle; NewTextStyle: TTextStyle; ListBox: TListBox absolute Control; - AMaskCaption, AMaskExample, AEditMask: String; R1, R2: TRect; begin ListBox.Canvas.FillRect(ARect); @@ -199,15 +171,12 @@ begin NewTextStyle.Layout := tlCenter; ListBox.Canvas.TextStyle := NewTextStyle; - ParseMaskLine(ListBox.Items[Index], AMaskCaption, AMaskExample, AEditMask); - AMaskExample := MaskDoFormatText(AEditMask, AMaskExample, FEnableSets); - R1 := ARect; R2 := ARect; R1.Right := (R1.Left + R1.Right) div 2; R2.Left := R1.Right + 1; - ListBox.Canvas.TextRect(R1, R1.Left + 2, R1.Top, AMaskCaption); - ListBox.Canvas.TextRect(R2, R2.Left + 2, R2.Top, AMaskExample); + ListBox.Canvas.TextRect(R1, R1.Left + 2, R1.Top, ParsedSamples[Index].Caption); + ListBox.Canvas.TextRect(R2, R2.Left + 2, R2.Top, ParsedSamples[Index].FormattedExample); ListBox.Canvas.MoveTo(R2.Left - 1, R2.Top); ListBox.Canvas.LineTo(R2.Left - 1, R2.Bottom); ListBox.Canvas.Brush.Style := OldBrushStyle; @@ -269,15 +238,11 @@ begin end; procedure TMaskEditorForm.SampleMasksListBoxClick(Sender: TObject); -var - AMaskCaption, AMaskExample, AEditMask: String; begin if (SampleMasksListBox.Items.Count > 0) then begin TestMaskEdit.Text := ''; - ParseMaskLine(SampleMasksListBox.Items[SampleMasksListBox.ItemIndex], - AMaskCaption, AMaskExample, AEditMask); - EditMask := AEditMask; + EditMask := ParsedSamples[SampleMasksListBox.ItemIndex].Mask; end; end; @@ -286,10 +251,174 @@ begin Result:=ConstructEditMask; end; +function TMaskEditorForm.MaskDoFormatText(const EditMask: string; const Value: string; EnableSets: Boolean): String; +var + P: Integer; + S, MaskPart: String; + MaskSave: Boolean; + SpaceChar: Char; +begin + // cheat maskutils while it has no its own MaskDoFormatText + SplitEditMask(EditMask, MaskPart, MaskSave, SpaceChar); + // in order to construct the displayed string from the "example text" field, + // we must set MaskSave to False and SpaceChar to #32, otherwise the result + // won't be the same as in Delphi + S := MaskPart+';0; '; + try + Result := FormatMaskText(S, Value, EnableSets); + except + Result := Value; + end; +end; + +function TMaskEditorForm.ParseMaskLineDelphi(Line: String; EnableSets: Boolean; out aCaption, aExample, aFormattedExample, aMask: String): Boolean; +var + P1, P2: SizeInt; +begin + { + in delphi .dem files every line is made up like this: + + Maskname + zero or more spaces + a pipe symbol (|) + one space + Example Text + one space + a pipe symbol (|) + one space + Editmask + zero or more spaces + + Trailing spaces from Maskname will be stripped + The first and last character from the Example Text field will be stripped away (hence they should be spaces) + The first character from the Editmask field will be stripped away, as well as trailing spaces + So notice that except for 2 places, whitespace is significant. + } + + Result := False; + //we need at least 2 | symbols + P1 := Pos('|', Line); + if (P1 = 0) then + Exit; + P2 := Pos('|', Line, P1 + 1); + if (P2 = 0) then + Exit; + aCaption := TrimRight(Copy(Line, 1, P1-1)); + if (aCaption = '') then + Exit; + aExample := (Copy(Line, P1+2, P2-P1-3)); + if (aExample = '') then + Exit; + aMask := TrimRight(Copy(Line,P2+2,MaxInt)); + if (aMask = '') then + Exit; + aFormattedExample := MaskDoFormatText(aMask, aExample, EnableSets); + Result := True; +end; + +function TMaskEditorForm.ParseMaskLineLazarus(Line: String; EnableSets: Boolean; out aCaption, aExample, aFormattedExample, aMask: String): Boolean; +var + P1, P2: SizeInt; +begin + { + in Lazarus .lem files every line is made up like this: + + Maskname + zero or more spaces + a pipe symbol (|) + zero or more spaces + Example Text + zero or more spaces + a pipe symbol (|) + zero or more spaces + Editmask + zero or more spaces + + Trailing spaces from Maskname will be stripped + Leading and trailing spaces from Example Text and EditMask will be stripped. + + Lines starting with '//' will be ignored + } + + Result := False; + if (TrimLeft(Line).StartsWith('//')) then + Exit; + //we need at least 2 | symbols + P1 := Pos('|', Line); + if (P1 = 0) then + Exit; + P2 := Pos('|', Line, P1 + 1); + if (P2 = 0) then + Exit; + aCaption := TrimRight(Copy(Line, 1, P1-1)); + if (aCaption = '') then + Exit; + aExample := Trim(Copy(Line, P1+1, P2-P1-1)); + if (aExample = '') then + Exit; + aMask := Trim(Copy(Line,P2+1,MaxInt)); + if (aMask = '') then + Exit; + aFormattedExample := MaskDoFormatText(aMask, aExample, EnableSets); + Result := True; +end; + + +procedure TMaskEditorForm.LoadAndCleanSampleFile(Fn: String; EnableSets: Boolean; List: TStrings; out AParsedSamples: TParsedSamples); +type + TParseFunc = function (Line: String; EnableSets: Boolean; out Caption, Example, FormattedExample, Mask: String): Boolean of Object; +var + i, Index: Integer; + S, aCaption, aExample, aFormattedExample, aMask: String; + SL: TStringList; + ParseFunc: TParseFunc; +begin + AParsedSamples := nil; + if (CompareText(ExtractFileExt(Fn),'.dem') = 0) then + ParseFunc := @ParseMaskLineDelphi + else + ParseFunc := @ParseMaskLineLazarus; + List.BeginUpdate; + List.Clear; + if not FileExistsUtf8(Fn) then + Exit; + SL := TStringList.Create; + try + try + SL.LoadFromFile(Fn, TEncoding.UTF8); + SetLength(AParsedSamples, SL.Count); + Index := 0; + for i := 0 to SL.Count - 1 do + begin + S := SL[i]; + if ParseFunc(S, EnableSets, aCaption, aExample, aFormattedExample, aMask) then + begin + AParsedSamples[Index].Caption := aCaption; + AParsedSamples[Index].Example := aExample; + AParsedSamples[Index].FormattedExample := aFormattedExample; + AParsedSamples[Index].Mask := aMask; + List.Add(S); + Inc(Index); + end; + end; + SetLength(AParsedSamples, Index); + except + on ESTreamError do + begin + List.Clear; + AParsedSamples := nil; + MessageDlg(Format(oisErrorReadingSampleFile,[Fn]), mtError, [mbOk], 0); + end; + end; + finally + List.EndUpdate; + SL.Free; + end; +end; + procedure TMaskEditorForm.LoadDEMFile(AFileName: string); begin - SampleMasksListBox.Items.Clear; - SampleMasksListBox.Items.LoadFromFile(UTF8ToSys(AFileName)); + LoadAndCleanSampleFile(AFilename, FEnableSets, SampleMasksListBox.Items, ParsedSamples); end; procedure TMaskEditorForm.SetEditMask(AValue: string); @@ -311,6 +440,7 @@ procedure TMaskEditorForm.SetEnableSets(AValue: Boolean); var OldMask: String; WasMasked: Boolean; + i: Integer; begin FEnableSets := AValue; WasMasked := TestMaskEdit.IsMasked; @@ -326,6 +456,13 @@ begin end; //since this is not only called from clicking on the checkbox EnableSetsCheckBox.Checked := FEnableSets; + for i := 0 to Length(ParsedSamples) - 1 do + begin + ParsedSamples[i].FormattedExample := MaskDoFormatText(ParsedSamples[i].Mask, ParsedSamples[i].Example, FEnableSets); + end; + SampleMasksListBox.Invalidate; + //since this is not only called from clicking on the checkbox + EnableSetsCheckBox.Checked := FEnableSets; end; procedure TMaskEditorForm.UpdateTestEditor; diff --git a/components/ideintf/objinspstrconsts.pas b/components/ideintf/objinspstrconsts.pas index 97b677026b..dcefc7df59 100644 --- a/components/ideintf/objinspstrconsts.pas +++ b/components/ideintf/objinspstrconsts.pas @@ -265,6 +265,9 @@ resourcestring oisTestInput = 'Test Input'; oisOpenMaskFile = 'Open masks file (*.dem)'; oisEnableSetsHint = 'Only affects the EnableSets property of the Test Input'; + oisMaskSampleFilter = 'EditMask sample files (*.lem;*.dem)|*.lem;*.dem|All files|(*)'; + oisErrorReadingSampleFile = 'Error reading file %s'; + cActionListEditorDialogCategory = 'Dialog'; cActionListEditorFileCategory = 'File'; cActionListEditorDatabaseCategory = 'Database';