Skip to content

armgit / Filee

Public Imported from GitHub
0

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.

Merge origin/main into feature/geospatial-conversion

KnifeLemone20104ac8a97
diff --cc src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs
index 0abffa01,864b8ccc..48bda6f9
--- a/src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs
@@@ -105,10 -111,11 +113,13 @@@ public sealed partial class GeneralPage
partial void OnKeepFileDatesChanged(bool value) => Save(s => s.KeepFileDates = value);
+ partial void OnZipGeoResultsChanged(bool value) => Save(s => s.ZipGeoResults = value);
+
[ObservableProperty] private Choice<string> _language;
[ObservableProperty] private bool _startWithSystem;
+ [ObservableProperty] private bool _showInDock;
+ [ObservableProperty] private bool _showMenuBarIcon;
+ [ObservableProperty] private string? _dockStatus;
[ObservableProperty] private bool _contextMenu;
[ObservableProperty] private string? _libraryMessage;
diff --cc src/Filee.Core/Presets/BuiltInData.cs
index 6d93d0dc,e5738307..d82a1c69
--- a/src/Filee.Core/Presets/BuiltInData.cs
+++ b/src/Filee.Core/Presets/BuiltInData.cs
@@@ -180,19 -179,6 +180,19 @@@ public static class BuiltInDat
new() { Id = "to-gltf", Name = "glTF", TargetFormat = "gltf" },
];
+ /// <summary>
- /// Geospatial vector targets (added in settings schema 24, see SettingsMigrations). CSV, the sixth slice of the
++ /// Geospatial vector targets (added in settings schema 25, 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 24, after "models").</summary>
++ /// <summary>Geospatial vector data: Shapefile, GeoJSON, KML, KMZ, GPX (added in settings schema 25, 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.cs
index 06c65f5e,79863577..b2473210
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@@ -64,7 -65,7 +65,7 @@@ public sealed class DonutSetting
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
-- public const int CurrentSchemaVersion = 24;
++ public const int CurrentSchemaVersion = 25;
public int SchemaVersion { get; set; } = CurrentSchemaVersion;
diff --cc src/Filee.Core/Settings/UserDataStore.cs
index 12004fe2,17dea6ea..cda39939
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@@ -368,17 -368,6 +368,17 @@@ internal static class SettingsMigration
InsertBefore(settings.EnginePriority, "model3d", settings.EnginePriority.Contains("archive") ? "archive" : "pandoc");
}
- // v24: built-in "geo" engine (GeoJSON, KML, KMZ, GPX, Shapefile and CSV points), after the 3D models engine (else
++ // v25: 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 < 24 && !settings.EnginePriority.Contains("geo"))
++ if (settings.SchemaVersion < 25 && !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"))
{
@@@ -638,10 -627,10 +638,14 @@@
// 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.
+ // v24: macro-enabled PowerPoint templates (.potm) open from the presentation donut next to POTX, unless a donut
+ // of the user already takes them.
if (from < 24)
+ changed |= LearnExtensions(profiles, out _, ["potm"]);
++ // v25: 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 < 25)
+ changed |= AddGeo(presets, profiles);
return changed;
}
diff --cc tests/Filee.Core.Tests/UserDataStoreTests.cs
index 727e02fd,5129bac7..d57b600a
--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs
+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs
@@@ -290,8 -422,7 +422,8 @@@ public class UserDataStoreTest
Assert.Equal(ids.IndexOf("text") + 1, ids.IndexOf("ebooks"));
Assert.Equal(ids.IndexOf("fonts") + 1, ids.IndexOf("data")); // schema 14
Assert.Equal(ids.IndexOf("data") + 1, ids.IndexOf("models")); // schema 15
- Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // schema 24
- Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("models"));
++ Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // schema 25
+ 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 -565,8 +566,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 24 the geospatial engine after the 3D models engine.
++ // from schema 25 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 -668,7 +671,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 24, the geospatial donut
- Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("models"));
++ Assert.Equal(ids.IndexOf("models") + 1, ids.IndexOf("geo")); // and, from schema 25, 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);
@@@ -606,93 -734,28 +738,116 @@@
}
[Fact]
- public void Version_23_libraries_get_geospatial_presets_and_their_donut_after_models()
+ public void Version_23_libraries_learn_potm_on_the_presentation_donut_and_nothing_else()
+ {
+ // As written with schema 23: no POTM, and the user took ODP off the presentation donut.
+ var presets = BuiltInData.CreatePresets();
+ var profiles = BuiltInData.CreateProfiles();
+ var slides = profiles.Single(p => p.Id == "presentations");
+ slides.Extensions.RemoveAll(e => e is "potm" or "odp");
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(23, presets, profiles));
+
+ Assert.Contains("potm", slides.Extensions);
+ Assert.DoesNotContain("odp", slides.Extensions);
+ Assert.False(SettingsMigrations.ApplyToLibrary(23, presets, profiles)); // once only
+
+ // A donut of the user that already opens .potm files keeps them.
+ profiles = BuiltInData.CreateProfiles();
+ profiles.Single(p => p.Id == "presentations").Extensions.Remove("potm");
+ profiles.Insert(0, new ToolbarProfile { Id = "templates", Name = "Templates", Extensions = ["potm"] });
+ Assert.False(SettingsMigrations.ApplyToLibrary(23, presets, profiles));
+ Assert.DoesNotContain("potm", profiles.Single(p => p.Id == "presentations").Extensions);
+ }
+
++ [Fact]
++ public void Version_24_libraries_get_geospatial_presets_and_their_donut_after_models()
+ {
- // As written with schema 23: no geospatial formats.
++ // As written with schema 24: 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(23, presets, profiles));
++ Assert.True(SettingsMigrations.ApplyToLibrary(24, 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(23, presets, profiles)); // once only
++ Assert.False(SettingsMigrations.ApplyToLibrary(24, 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(23, presets, profiles));
++ Assert.True(SettingsMigrations.ApplyToLibrary(24, 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(23, withoutPresets, taken)); // the presets are still added
++ Assert.True(SettingsMigrations.ApplyToLibrary(24, 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(23, presets, profiles);
++ SettingsMigrations.ApplyToLibrary(24, 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_23_settings_get_the_geo_engine_after_the_3d_models_engine()
++ public void Version_24_settings_get_the_geo_engine_after_the_3d_models_engine()
+ {
+ using var dir = new TempDir();
+ File.WriteAllText(Path.Combine(dir.Path, "settings.json"),
- """{ "schemaVersion": 23, "enginePriority": ["magick", "cad", "model3d", "archive", "pandoc", "libreoffice"] }""");
++ """{ "schemaVersion": 24, "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()
{