Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Merge origin/main into feature/geospatial-conversion
KnifeLemon0a2aff96d930
diff --cc src/Filee.App/Assets/i18n/en.jsonindex 6ff3468f,976f4200..9b7338e2--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@@ -78,23 -78,9 +78,24 @@@"error.not_enough_space": "Not enough free disk space for the pictures","error.rhwp_timeout": "rhwp couldn't finish this long document in time","error.rhwp_timeout_calibre": "rhwp couldn't finish this long document in time. For an e-book, move Calibre above the HWPX writer in Settings → Engines, and Calibre makes the PDF much faster",+ "error.needs_shaping": "This script needs LibreOffice to convert correctly. Install it in Settings → Engines","error.conversion_failed": "The engine reported an error",+ "error.geo_empty": "The file has no features",+ "error.geo_unknown_crs": "The coordinates are not longitude and latitude, and the file doesn't name its coordinate system (next to a Shapefile, keep its .prj file)",+ "error.geo_unsupported_crs": "This coordinate system isn't supported yet",+ "error.geo_bad_coordinates": "The coordinates don't fit this coordinate system",+ "error.geo_csv_no_coordinates": "The CSV has no longitude/latitude columns and no WKT column",+ "error.geo_csv_no_locations": "No row of the CSV has a usable location",+ "error.geo_unsupported_shape": "This kind of shape isn't supported",+ "error.geo_too_large": "The Shapefile would pass the format's 2 GB limit","notice.pdf_not_smaller": "Couldn't make it smaller, so it was copied as it is",+ "notice.geo_datum_assumed": "The datum isn't WGS 84; positions were converted as if it were and can be off by up to hundreds of metres",+ "notice.geo_gpx_lossy": "GPX holds only points, routes and tracks with a few fields: other attributes were left out and polygons became tracks",+ "notice.geo_text_cut": "Some text was longer than a Shapefile field allows (254 bytes) and was cut",+ "notice.geo_columns_dropped": "A Shapefile holds 255 columns at most: the rest were left out",+ "notice.geo_rows_without_location": "Some rows have no usable location and were kept without a shape",+ "notice.geo_field_names": "Shapefile field names are 10 characters at most: some were shortened",+ "notice.geo_shapefile_split": "A Shapefile holds one kind of shape, so points, lines and polygons were saved as separate files","engine.reason.not_installed": "Not installed","engine.reason.error": "Error while checking",diff --cc src/Filee.App/Assets/i18n/es.jsonindex a9c32177,a90d3ef4..25993002--- a/src/Filee.App/Assets/i18n/es.json+++ b/src/Filee.App/Assets/i18n/es.json@@@ -72,23 -72,9 +72,24 @@@"error.not_enough_space": "Espacio libre en disco insuficiente para las imágenes","error.rhwp_timeout": "rhwp no pudo terminar este documento largo a tiempo","error.rhwp_timeout_calibre": "rhwp no pudo terminar este documento largo a tiempo. Para un libro electrónico, mueve Calibre por encima del escritor HWPX en Ajustes → Motores; Calibre genera el PDF mucho más rápido",+ "error.needs_shaping": "Este sistema de escritura necesita LibreOffice para convertirse bien. Instálalo en Ajustes → Motores","error.conversion_failed": "El motor devolvió un error",+ "error.geo_empty": "El archivo no contiene ningún elemento",+ "error.geo_unknown_crs": "Las coordenadas no son longitud y latitud y el archivo no indica su sistema de coordenadas (junto a un Shapefile, conserva su archivo .prj)",+ "error.geo_unsupported_crs": "Este sistema de coordenadas aún no es compatible",+ "error.geo_bad_coordinates": "Las coordenadas no encajan en este sistema de coordenadas",+ "error.geo_csv_no_coordinates": "El CSV no tiene columnas de longitud/latitud ni una columna WKT",+ "error.geo_csv_no_locations": "Ninguna fila del CSV tiene una ubicación utilizable",+ "error.geo_unsupported_shape": "Este tipo de forma no es compatible",+ "error.geo_too_large": "El Shapefile superaría el límite de 2 GB del formato","notice.pdf_not_smaller": "No se pudo reducir su tamaño, por lo que se copió tal cual",+ "notice.geo_datum_assumed": "El datum no es WGS 84; las posiciones se convirtieron como si lo fuera y pueden desviarse hasta cientos de metros",+ "notice.geo_gpx_lossy": "GPX solo guarda puntos, rutas y tracks con pocos campos: se omitieron los demás atributos y los polígonos pasaron a ser tracks",+ "notice.geo_text_cut": "Parte del texto superaba la longitud de campo de Shapefile (254 bytes) y se recortó",+ "notice.geo_columns_dropped": "Un Shapefile admite 255 columnas como máximo: se omitió el resto",+ "notice.geo_rows_without_location": "Las filas sin ubicación utilizable se guardaron sin forma",+ "notice.geo_field_names": "Los nombres de campo de Shapefile tienen 10 caracteres como máximo: se acortaron algunos",+ "notice.geo_shapefile_split": "Un Shapefile guarda un solo tipo de forma, así que puntos, líneas y polígonos se guardaron en archivos separados","engine.reason.not_installed": "No instalado","engine.reason.error": "Error al comprobar","engine.reason.unsupported_platform": "No disponible en esta plataforma",diff --cc src/Filee.App/Assets/i18n/ko.jsonindex be8b80f9,28d4ff54..90135b4c--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@@ -78,23 -78,9 +78,24 @@@"error.not_enough_space": "이미지를 저장할 디스크 공간이 부족해요","error.rhwp_timeout": "문서가 길어서 rhwp가 제한 시간 안에 끝내지 못했어요","error.rhwp_timeout_calibre": "문서가 길어서 rhwp가 제한 시간 안에 끝내지 못했어요. 전자책이라면 설정 → 변환 엔진에서 Calibre를 HWPX writer보다 위로 옮겨 주세요. Calibre가 PDF를 훨씬 빨리 만들어요",+ "error.needs_shaping": "이 문자는 LibreOffice가 있어야 제대로 변환돼요. 설정 → 변환 엔진에서 설치해 주세요","error.conversion_failed": "엔진에서 오류가 발생했어요",+ "error.geo_empty": "파일에 지리 객체가 없어요",+ "error.geo_unknown_crs": "좌표가 경도·위도가 아닌데 좌표계 정보도 없어요 (Shapefile은 .prj 파일을 함께 두세요)",+ "error.geo_unsupported_crs": "아직 지원하지 않는 좌표계예요",+ "error.geo_bad_coordinates": "좌표가 이 좌표계의 범위를 벗어났어요",+ "error.geo_csv_no_coordinates": "CSV에서 경도·위도 열이나 WKT 열을 찾지 못했어요",+ "error.geo_csv_no_locations": "위치를 읽을 수 있는 행이 하나도 없어요",+ "error.geo_unsupported_shape": "지원하지 않는 도형 종류예요",+ "error.geo_too_large": "Shapefile의 한계인 2GB를 넘어요","notice.pdf_not_smaller": "더 작게 만들 수 없어서 그대로 복사했어요",+ "notice.geo_datum_assumed": "측지계가 WGS 84가 아니라서 같은 것으로 보고 변환했어요. 위치가 수백 m까지 어긋날 수 있어요",+ "notice.geo_gpx_lossy": "GPX는 점·경로·트랙과 몇 가지 항목만 담아요. 다른 속성은 빠졌고 면은 트랙으로 바뀌었어요",+ "notice.geo_text_cut": "Shapefile 필드 길이(254바이트)보다 긴 글자는 잘렸어요",+ "notice.geo_columns_dropped": "Shapefile은 열을 255개까지만 담아서 나머지는 뺐어요",+ "notice.geo_rows_without_location": "위치를 읽을 수 없는 행은 도형 없이 저장했어요",+ "notice.geo_field_names": "Shapefile 필드 이름은 10자까지라서 일부를 줄였어요",+ "notice.geo_shapefile_split": "Shapefile은 한 종류의 도형만 담아서 점·선·면을 파일로 나눠 저장했어요","engine.reason.not_installed": "설치되지 않음","engine.reason.error": "확인 중 오류",diff --cc src/Filee.App/Assets/i18n/pl.jsonindex 8ca67a78,eaa36e60..eab3d20d--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@@ -78,23 -78,9 +78,24 @@@"error.not_enough_space": "Za mało wolnego miejsca na dysku na obrazy","error.rhwp_timeout": "rhwp nie zdążył przetworzyć tego długiego dokumentu","error.rhwp_timeout_calibre": "rhwp nie zdążył przetworzyć tego długiego dokumentu. Dla e-booka przenieś Calibre nad HWPX writer w Ustawienia → Silniki, a Calibre zrobi PDF znacznie szybciej",+ "error.needs_shaping": "To pismo wymaga LibreOffice do poprawnej konwersji. Zainstaluj go w Ustawienia → Silniki","error.conversion_failed": "Silnik zgłosił błąd",+ "error.geo_empty": "Plik nie zawiera żadnych obiektów",+ "error.geo_unknown_crs": "Współrzędne nie są długością i szerokością geograficzną, a plik nie podaje układu współrzędnych (przy Shapefile zachowaj obok plik .prj)",+ "error.geo_unsupported_crs": "Ten układ współrzędnych nie jest jeszcze obsługiwany",+ "error.geo_bad_coordinates": "Współrzędne nie mieszczą się w tym układzie współrzędnych",+ "error.geo_csv_no_coordinates": "W pliku CSV nie ma kolumn długości i szerokości geograficznej ani kolumny WKT",+ "error.geo_csv_no_locations": "Żaden wiersz pliku CSV nie ma odczytywalnego położenia",+ "error.geo_unsupported_shape": "Ten rodzaj kształtu nie jest obsługiwany",+ "error.geo_too_large": "Shapefile przekroczyłby limit 2 GB tego formatu","notice.pdf_not_smaller": "Nie udało się zmniejszyć pliku, więc skopiowano go bez zmian",+ "notice.geo_datum_assumed": "Datum nie jest WGS 84; pozycje przeliczono tak, jakby było, więc mogą się różnić nawet o setki metrów",+ "notice.geo_gpx_lossy": "GPX przechowuje tylko punkty, trasy i ślady z kilkoma polami: pozostałe atrybuty pominięto, a poligony stały się śladami",+ "notice.geo_text_cut": "Część tekstu była dłuższa niż pole Shapefile (254 bajty) i została przycięta",+ "notice.geo_columns_dropped": "Shapefile ma najwyżej 255 kolumn: resztę pominięto",+ "notice.geo_rows_without_location": "Wiersze bez odczytywalnego położenia zapisano bez kształtu",+ "notice.geo_field_names": "Nazwy pól Shapefile mają najwyżej 10 znaków: niektóre skrócono",+ "notice.geo_shapefile_split": "Shapefile przechowuje jeden rodzaj kształtu, więc punkty, linie i poligony zapisano w osobnych plikach","engine.reason.not_installed": "Nie zainstalowano","engine.reason.error": "Błąd podczas sprawdzania",diff --cc src/Filee.App/Assets/i18n/zh-CN.jsonindex 497e54cb,d45972b6..fc26d763--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@@ -78,23 -78,9 +78,24 @@@"error.not_enough_space": "磁盘空间不足,无法保存这些图片","error.rhwp_timeout": "文档太长,rhwp 未能在时限内完成","error.rhwp_timeout_calibre": "文档太长,rhwp 未能在时限内完成。如果是电子书,请在“设置 → 转换引擎”中把 Calibre 移到 HWPX writer 之上,Calibre 生成 PDF 要快得多",+ "error.needs_shaping": "这种文字需要 LibreOffice 才能正确转换,请在“设置 → 转换引擎”中安装","error.conversion_failed": "转换引擎出错",+ "error.geo_empty": "文件中没有地理要素",+ "error.geo_unknown_crs": "坐标不是经纬度,文件也没有说明坐标系(Shapefile 请把 .prj 文件放在旁边)",+ "error.geo_unsupported_crs": "暂不支持此坐标系",+ "error.geo_bad_coordinates": "坐标超出了该坐标系的范围",+ "error.geo_csv_no_coordinates": "CSV 中没有经纬度列,也没有 WKT 列",+ "error.geo_csv_no_locations": "CSV 中没有一行能读出位置",+ "error.geo_unsupported_shape": "不支持此类形状",+ "error.geo_too_large": "将超过 Shapefile 2 GB 的上限","notice.pdf_not_smaller": "无法再缩小,已原样复制",+ "notice.geo_datum_assumed": "基准面不是 WGS 84,已按相同处理,位置可能偏差数百米",+ "notice.geo_gpx_lossy": "GPX 只能保存点、路线和轨迹及少数字段:其他属性已省略,面变成了轨迹",+ "notice.geo_text_cut": "部分文字超过 Shapefile 字段长度(254 字节),已被截断",+ "notice.geo_columns_dropped": "Shapefile 最多 255 列,多出的列已省略",+ "notice.geo_rows_without_location": "部分行无法读出位置,已不带形状保存",+ "notice.geo_field_names": "Shapefile 字段名最多 10 个字符,部分名称已缩短",+ "notice.geo_shapefile_split": "Shapefile 只能保存一种形状,因此点、线、面被分别存成了多个文件","engine.reason.not_installed": "未安装","engine.reason.error": "检查时出错",diff --cc src/Filee.Core/Conversion/JobQueue.csindex 42fd66b2,03aa3dc0..6462d243--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@@ -493,43 -501,20 +506,57 @@@ public sealed class JobQueue : IAsyncDi}}+ /// <summary>+ /// Packs the files one source was converted to into one ZIP (named by the preset's output rule, so the conflict+ /// policy applies to it) and returns it; empty when the rule says to skip an existing ZIP. Files keep their names+ /// inside, a clash gets "name (2).ext", and a ZIP that can't be completed is deleted.+ /// </summary>+ private IReadOnlyList<string> PackZip(ConversionJob job, FileResult file, int index, IReadOnlyList<string> files, CancellationToken ct)+ {+ if (CreateFinalAllocator(job, file.SourcePath, index).Allocate("zip") is not { } zipPath)+ return [];+ try+ {+ using (var stream = new FileStream(zipPath, FileMode.Create, FileAccess.Write, FileShare.None, 1 << 16))+ using (var archive = new System.IO.Compression.ZipArchive(stream, System.IO.Compression.ZipArchiveMode.Create))+ {+ var used = new HashSet<string>(StringComparer.OrdinalIgnoreCase);+ foreach (var path in files)+ {+ ct.ThrowIfCancellationRequested();+ var name = Path.GetFileName(path);+ for (var n = 2; !used.Add(name); n++)+ name = $"{Path.GetFileNameWithoutExtension(path)} ({n}){Path.GetExtension(path)}";+ System.IO.Compression.ZipFileExtensions.CreateEntryFromFile(archive, path, name, System.IO.Compression.CompressionLevel.Optimal);+ }+ }+ }+ catch+ {+ try+ {+ File.Delete(zipPath);+ }+ catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { }+ throw;+ }+ return [zipPath];+ }++ /// <summary>The engine's check; a check that fails (an unreadable file) finds nothing, and the conversion reports the file.</summary>+ private string? ScriptNeedingShaping(ITextShapingCheck check, string path, string format)+ {+ try+ {+ return check.ScriptNeedingShaping(path, format);+ }+ catch (Exception ex)+ {+ _log.LogWarning(ex, "Could not check the scripts of {File}", path);+ return null;+ }+ }+private SemaphoreSlim GateFor(IConverter converter) =>_engineGates.GetOrAdd(converter.Id, _ =>{diff --cc src/Filee.Core/Presets/BuiltInData.csindex b34fa67e,e5738307..6d93d0dc--- a/src/Filee.Core/Presets/BuiltInData.cs+++ b/src/Filee.Core/Presets/BuiltInData.cs@@@ -180,19 -179,6 +180,19 @@@ public static class BuiltInDatnew() { Id = "to-gltf", Name = "glTF", TargetFormat = "gltf" },];+ /// <summary>- /// Geospatial vector targets (added in settings schema 23, see SettingsMigrations). CSV, the sixth slice of the++ /// Geospatial vector targets (added in settings schema 24, see SettingsMigrations). CSV, the sixth slice of the+ /// donut, is the spreadsheet preset. KMZ is a KML in a ZIP and is on no donut.+ /// </summary>+ public static List<Preset> GeoPresets() =>+ [+ new() { Id = "to-geojson", Name = "GeoJSON", TargetFormat = "geojson" },+ new() { Id = "to-shp", Name = "Shapefile", TargetFormat = "shp" },+ new() { Id = "to-kml", Name = "KML", TargetFormat = "kml" },+ new() { Id = "to-gpx", Name = "GPX", TargetFormat = "gpx" },+ new() { Id = "to-kmz", Name = "KMZ", TargetFormat = "kmz" },+ ];+/// <summary>/// Targets of the formats added in settings schema 6: images, vector, office, e-books, video, audio, archives,/// CAD and fonts (see SettingsMigrations).@@@ -485,15 -470,6 +485,15 @@@PresetIds = ["to-glb", "to-stl", "to-obj", "to-3mf", "to-ply", "to-png"],};- /// <summary>Geospatial vector data: Shapefile, GeoJSON, KML, KMZ, GPX (added in settings schema 23, after "models").</summary>++ /// <summary>Geospatial vector data: Shapefile, GeoJSON, KML, KMZ, GPX (added in settings schema 24, after "models").</summary>+ public static ToolbarProfile GeoProfile() => new()+ {+ Id = "geo",+ NameKey = "profile.geo",+ Extensions = ExtensionsOf(FormatCategory.Geo),+ PresetIds = ["to-geojson", "to-shp", "to-kml", "to-csv", "to-gpx", "to-kmz"],+ };+/// <summary>Every file extension of the formats in <paramref name="category"/>.</summary>public static List<string> ExtensionsOf(FormatCategory category) =>FormatRegistry.Known.Where(f => f.Category == category)diff --cc src/Filee.Core/Settings/AppSettings.csindex 173fa2ba,7ec34b1d..06c65f5e--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@@ -64,7 -64,7 +64,7 @@@ public sealed class DonutSettingpublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>-- public const int CurrentSchemaVersion = 23;++ public const int CurrentSchemaVersion = 24;public int SchemaVersion { get; set; } = CurrentSchemaVersion;diff --cc src/Filee.Core/Settings/UserDataStore.csindex 125b7223,dc76cec6..12004fe2--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@@ -308,17 -368,6 +368,17 @@@ internal static class SettingsMigrationInsertBefore(settings.EnginePriority, "model3d", settings.EnginePriority.Contains("archive") ? "archive" : "pandoc");}- // v23: built-in "geo" engine (GeoJSON, KML, KMZ, GPX, Shapefile and CSV points), after the 3D models engine (else++ // v24: built-in "geo" engine (GeoJSON, KML, KMZ, GPX, Shapefile and CSV points), after the 3D models engine (else+ // before the archive engine, else before Pandoc).- if (settings.SchemaVersion < 23 && !settings.EnginePriority.Contains("geo"))++ if (settings.SchemaVersion < 24 && !settings.EnginePriority.Contains("geo"))+ {+ var models = settings.EnginePriority.IndexOf("model3d");+ if (models >= 0)+ settings.EnginePriority.Insert(models + 1, "geo");+ else+ InsertBefore(settings.EnginePriority, "geo", settings.EnginePriority.Contains("archive") ? "archive" : "pandoc");+ }+// v18: built-in "pdf-slides" engine (PDF → PPTX, a picture of each page per slide), after "pdf-text".if (settings.SchemaVersion < 18 && !settings.EnginePriority.Contains("pdf-slides")){@@@ -574,10 -623,10 +634,14 @@@// takes it. Other extensions the user removed from a built-in donut stay removed.if (from < 22)changed |= LearnExtensions(profiles, out _, ["fbx"]);- // v23: geospatial vector data (Shapefile, GeoJSON, KML, KMZ, GPX) gets presets and its own donut after "models"- // (else after "data", else after "fonts"), with the extensions no donut of the user takes yet.+ // v23: MHTML web archives (.mhtml, .mht; read only) open from the text donut next to HTML, unless a donut of+ // the user already takes them.if (from < 23)+ changed |= LearnExtensions(profiles, out _, ["mhtml", "mht"]);++ // v24: geospatial vector data (Shapefile, GeoJSON, KML, KMZ, GPX) gets presets and its own donut after "models"++ // (else after "data", else after "fonts"), with the extensions no donut of the user takes yet.++ if (from < 24)+ changed |= AddGeo(presets, profiles);return changed;}diff --cc tests/Filee.Core.Tests/UserDataStoreTests.csindex d786bfe5,09a31904..727e02fd--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs@@@ -290,8 -290,7 +290,8 @@@ public class UserDataStoreTestAssert.Equal(ids.IndexOf("text") + 1, ids.IndexOf("ebooks"));Assert.Equal(ids.IndexOf("fonts") + 1, ids.IndexOf("data")); // schema 14Assert.Equal(ids.IndexOf("data") + 1, ids.IndexOf("models")); // schema 15- Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // schema 21- Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("models"));++ Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // schema 24+ Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("geo"));Assert.Equal(ids.IndexOf("audio") + 1, ids.IndexOf("subtitles"));Assert.Contains("cr2", profiles.Single(p => p.Id == "images").Extensions);Assert.DoesNotContain("mp3", profiles.Single(p => p.Id == "audio").Extensions);@@@ -434,9 -433,8 +434,9 @@@store.Load();// ... and, from schema 15, the 3D model engine before Pandoc (no CAD or archive engine in this list), from- // schema 18 the PDF slides engine there too (no PDF text engine), from schema 21 the WIC engine (no FFmpeg).- Assert.Equal(["magick", "email", "data", "vector", "model3d", "pdf-slides", "wic", "pandoc", "libreoffice"], store.Settings.EnginePriority);+ // schema 18 the PDF slides engine there too (no PDF text engine), from schema 21 the WIC engine (no FFmpeg),- // from schema 23 the geospatial engine after the 3D models engine.++ // from schema 24 the geospatial engine after the 3D models engine.+ Assert.Equal(["magick", "email", "data", "vector", "model3d", "geo", "pdf-slides", "wic", "pandoc", "libreoffice"], store.Settings.EnginePriority);}[Fact]@@@ -539,8 -536,7 +539,8 @@@Assert.Equal(["to-glb", "to-stl", "to-obj", "to-3mf", "to-ply", "to-gltf"], presets.Where(p => modelIds.Contains(p.Id)).Select(p => p.Id));var ids = profiles.Select(p => p.Id).ToList();Assert.Equal(ids.IndexOf("data") + 1, ids.IndexOf("models"));- Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // and, from schema 21, the geospatial donut- Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("models"));++ Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // and, from schema 24, the geospatial donut+ Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("geo"));var models = profiles.Single(p => p.Id == "models");Assert.Equal(["glb", "gltf", "stl", "obj", "3mf", "ply", "fbx"], models.Extensions);Assert.Equal(BuiltInData.ModelProfile().PresetIds, models.PresetIds);@@@ -582,93 -578,29 +582,117 @@@}[Fact]- public void Version_22_libraries_get_geospatial_presets_and_their_donut_after_models()+ public void Version_22_libraries_learn_mhtml_on_the_text_donut_and_nothing_else(){- // As written with schema 22: no geospatial formats.+ // As written with schema 22: no MHTML, and the user took Markdown off the text donut.+ var presets = BuiltInData.CreatePresets();+ var profiles = BuiltInData.CreateProfiles();+ var text = profiles.Single(p => p.Id == "text");+ text.Extensions.RemoveAll(e => e is "mhtml" or "mht" or "md" or "markdown");++ Assert.True(SettingsMigrations.ApplyToLibrary(22, presets, profiles));++ Assert.Contains("mhtml", text.Extensions);+ Assert.Contains("mht", text.Extensions);+ Assert.DoesNotContain("md", text.Extensions);+ Assert.False(SettingsMigrations.ApplyToLibrary(22, presets, profiles)); // once only++ // A donut of the user that already opens .mht files keeps them; .mhtml still goes to the text donut.+ profiles = BuiltInData.CreateProfiles();+ profiles.Single(p => p.Id == "text").Extensions.RemoveAll(e => e is "mhtml" or "mht");+ profiles.Insert(0, new ToolbarProfile { Id = "web", Name = "Web", Extensions = ["mht"] });+ Assert.True(SettingsMigrations.ApplyToLibrary(22, presets, profiles));+ Assert.Equal(["mhtml"], profiles.Single(p => p.Id == "text").Extensions.Where(e => e.StartsWith("mht", StringComparison.Ordinal)));+ }+++ [Fact]++ public void Version_23_libraries_get_geospatial_presets_and_their_donut_after_models()++ {++ // As written with schema 23: no geospatial formats.+ var geoIds = BuiltInData.GeoPresets().Select(p => p.Id).ToHashSet();+ var presets = BuiltInData.CreatePresets().Where(p => !geoIds.Contains(p.Id)).ToList();+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "geo").ToList();+- Assert.True(SettingsMigrations.ApplyToLibrary(22, presets, profiles));++ Assert.True(SettingsMigrations.ApplyToLibrary(23, presets, profiles));++ Assert.Equal(["to-geojson", "to-shp", "to-kml", "to-gpx", "to-kmz"], presets.Where(p => geoIds.Contains(p.Id)).Select(p => p.Id));+ Assert.Equal(["geojson", "shp", "kml", "gpx"], presets.Where(p => geoIds.Contains(p.Id)).Select(p => p.TargetFormat).Take(4));+ var ids = profiles.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo"));+ Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("geo"));+ var geo = profiles.Single(p => p.Id == "geo");+ Assert.Equal(["geojson", "kml", "kmz", "gpx", "shp"], geo.Extensions);+ Assert.Equal(BuiltInData.GeoProfile().PresetIds, geo.PresetIds);+ Assert.All(geo.PresetIds, id => Assert.Contains(presets, p => p.Id == id));- Assert.False(SettingsMigrations.ApplyToLibrary(22, presets, profiles)); // once only++ Assert.False(SettingsMigrations.ApplyToLibrary(23, presets, profiles)); // once only+ }++ [Fact]+ public void The_geospatial_donut_leaves_out_extensions_a_profile_of_the_user_takes_and_is_skipped_when_all_are_taken()+ {+ var presets = BuiltInData.CreatePresets();+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "geo").ToList();+ profiles.Insert(0, new ToolbarProfile { Id = "earth", Name = "Earth", Extensions = ["kml", "kmz"] });+- Assert.True(SettingsMigrations.ApplyToLibrary(22, presets, profiles));++ Assert.True(SettingsMigrations.ApplyToLibrary(23, presets, profiles));+ Assert.Equal(["geojson", "gpx", "shp"], profiles.Single(p => p.Id == "geo").Extensions);++ var taken = BuiltInData.CreateProfiles().Where(p => p.Id != "geo").ToList();+ taken.Insert(0, new ToolbarProfile { Id = "all", Name = "All", Extensions = ["geojson", "kml", "kmz", "gpx", "shp"] });+ var geoIds = BuiltInData.GeoPresets().Select(p => p.Id).ToHashSet();+ var withoutPresets = BuiltInData.CreatePresets().Where(p => !geoIds.Contains(p.Id)).ToList();+- Assert.True(SettingsMigrations.ApplyToLibrary(22, withoutPresets, taken)); // the presets are still added++ Assert.True(SettingsMigrations.ApplyToLibrary(23, withoutPresets, taken)); // the presets are still added+ Assert.DoesNotContain(taken, p => p.Id == "geo");+ Assert.Contains(withoutPresets, p => p.Id == "to-shp");+ }++ [Fact]+ public void A_geospatial_donut_of_the_user_is_not_replaced()+ {+ var presets = BuiltInData.CreatePresets();+ var profiles = BuiltInData.CreateProfiles();+ var mine = profiles.Single(p => p.Id == "geo");+ mine.PresetIds = ["to-kml"];+ mine.Extensions = ["kml"];+- SettingsMigrations.ApplyToLibrary(22, presets, profiles);++ SettingsMigrations.ApplyToLibrary(23, presets, profiles);++ var geo = profiles.Single(p => p.Id == "geo");+ Assert.Equal(["to-kml"], geo.PresetIds);+ // The extensions of the default donut that no donut takes yet are added to it, after the user's own.+ Assert.Equal(["kml", "geojson", "kmz", "gpx", "shp"], geo.Extensions);+ }++ [Fact]- public void Version_22_settings_get_the_geo_engine_after_the_3d_models_engine()++ public void Version_23_settings_get_the_geo_engine_after_the_3d_models_engine()+ {+ using var dir = new TempDir();+ File.WriteAllText(Path.Combine(dir.Path, "settings.json"),- """{ "schemaVersion": 22, "enginePriority": ["magick", "cad", "model3d", "archive", "pandoc", "libreoffice"] }""");++ """{ "schemaVersion": 23, "enginePriority": ["magick", "cad", "model3d", "archive", "pandoc", "libreoffice"] }""");++ var store = new UserDataStore(dir.Path);+ store.Load();++ Assert.Equal(["magick", "cad", "model3d", "geo", "archive", "pandoc", "libreoffice"], store.Settings.EnginePriority);+ Assert.Equal(AppSettings.CurrentSchemaVersion, store.Settings.SchemaVersion);+ }++ [Fact]+ public void A_new_library_has_the_geospatial_donut_with_presets_that_exist()+ {+ using var dir = new TempDir();+ var store = new UserDataStore(dir.Path);+ store.Load();++ var ids = store.Profiles.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo"));+ var geo = store.Profiles.Single(p => p.Id == "geo");+ Assert.All(geo.PresetIds, id => Assert.NotNull(store.FindPreset(id)));+ Assert.Equal("shp", store.FindPreset("to-shp")!.TargetFormat);+ Assert.Equal("csv", store.FindPreset("to-csv")!.TargetFormat);+ }+[Fact]public void Version_15_libraries_get_the_tracing_presets_on_the_images_donut_after_pdf(){