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
fix(spreadsheet): open independent studios for workbook drops
Perricheno0aa3ccbad879
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 37b41e96..06c5ded9 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -148,8 +148,8 @@ multi-frame pictures refused, the EXIF thumbnail dropped), one history entry for## Spreadsheet print studio-The `tool-sheet-studio` tool opens `Views/SpreadsheetPrintStudioWindow` for one XLSX workbook instead of starting a-normal conversion job. `SpreadsheetPrintStudioViewModel` owns an ordered, non-destructive print plan: each visible+The `tool-sheet-studio` tool opens an independent `Views/SpreadsheetPrintStudioWindow` for each dropped XLSX workbook+instead of starting a normal conversion job. `SpreadsheetPrintStudioViewModel` owns an ordered, non-destructive print plan: each visiblesheet starts as one region and the user can add more regions, change paper, orientation, scale, margins, page order,hidden rows and manual breaks, then see the PDF that those settings will produce.diff --git a/src/Filee.App/Services/PresetAvailability.cs b/src/Filee.App/Services/PresetAvailability.csindex 61bab762..6bb239d8 100644--- a/src/Filee.App/Services/PresetAvailability.cs+++ b/src/Filee.App/Services/PresetAvailability.cs@@ -92,7 +92,7 @@ public sealed class PresetAvailability{if (preset.Id == "tool-sheet-studio"){- if (formats.Count == 1 && formats[0].Id == "xlsx")+ if (formats.Count > 0 && formats.All(format => format.Id == "xlsx")){var libreOffice = _catalog.All.FirstOrDefault(converter => converter.Id == "libreoffice");if (libreOffice?.GetStatus().IsAvailable == true)diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.csindex 572c93c7..c886b668 100644--- a/src/Filee.App/Services/RadialController.cs+++ b/src/Filee.App/Services/RadialController.cs@@ -380,8 +380,8 @@ public sealed class RadialController({if (preset.Id == "tool-sheet-studio"){- if (files.Count == 1 && Path.GetExtension(files[0]).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))- windows.ShowSpreadsheetPrintStudio(files[0]);+ foreach (var workbook in files.Where(file => Path.GetExtension(file).Equals(".xlsx", StringComparison.OrdinalIgnoreCase)))+ windows.ShowSpreadsheetPrintStudio(workbook);}elsewindows.ShowCropOverlay(files, preset, near);diff --git a/src/Filee.App/Services/WindowService.cs b/src/Filee.App/Services/WindowService.csindex 436ff152..e5ada4e6 100644--- a/src/Filee.App/Services/WindowService.cs+++ b/src/Filee.App/Services/WindowService.cs@@ -30,7 +30,9 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Meminternal FormatRequestNoticeWindow? FormatRequestNotice => _formatRequestNotice;private CropOverlayWindow? _cropOverlay;- private SpreadsheetPrintStudioWindow? _spreadsheetStudio;+ private readonly HashSet<SpreadsheetPrintStudioWindow> _spreadsheetStudios = [];++ internal IReadOnlyCollection<SpreadsheetPrintStudioWindow> SpreadsheetStudios => _spreadsheetStudios;private MergeOrderWindow? _mergeOrder;internal MergeOrderWindow? MergeOrder => _mergeOrder;@@ -79,7 +81,6 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Mem/// <summary>Opens the non-destructive XLSX print studio. One workbook owns one window and print plan.</summary>public void ShowSpreadsheetPrintStudio(string file){- _spreadsheetStudio?.Close();SpreadsheetPrintStudioViewModel vm;try{@@ -94,11 +95,10 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Memvar window = new SpreadsheetPrintStudioWindow { DataContext = vm };window.Closed += (_, _) =>{- if (_spreadsheetStudio == window)- _spreadsheetStudio = null;+ _spreadsheetStudios.Remove(window);trimmer.Request();};- _spreadsheetStudio = window;+ _spreadsheetStudios.Add(window);window.Show();window.Activate();}diff --git a/src/Filee.App/Views/SpreadsheetPrintStudioWindow.axaml b/src/Filee.App/Views/SpreadsheetPrintStudioWindow.axamlindex bd7e8f5f..9b3204c0 100644--- a/src/Filee.App/Views/SpreadsheetPrintStudioWindow.axaml+++ b/src/Filee.App/Views/SpreadsheetPrintStudioWindow.axaml@@ -103,27 +103,31 @@<TextBlock Text="{DynamicResource sheet_studio.print_area}" /><Grid ColumnDefinitions="*,Auto" ColumnSpacing="6">- <TextBox Grid.Column="0" Text="{Binding SelectedSheet.Range}" />+ <TextBox Grid.Column="0" Text="{Binding SelectedSheet.Range}"+ AutomationProperties.Name="{DynamicResource sheet_studio.print_area}" /><Button Grid.Column="1" Content="{DynamicResource sheet_studio.use_content}" Command="{Binding UseContentRangeCommand}" /></Grid><Grid ColumnDefinitions="*,*" ColumnSpacing="10"><StackPanel Grid.Column="0" Spacing="5"><TextBlock Text="{DynamicResource sheet_studio.paper}" />- <ComboBox ItemsSource="{Binding Papers}" SelectedValue="{Binding SelectedSheet.Paper}" SelectedValueBinding="{Binding Value}">+ <ComboBox ItemsSource="{Binding Papers}" SelectedValue="{Binding SelectedSheet.Paper}" SelectedValueBinding="{Binding Value}"+ AutomationProperties.Name="{DynamicResource sheet_studio.paper}"><ComboBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Label}" /></DataTemplate></ComboBox.ItemTemplate></ComboBox></StackPanel><StackPanel Grid.Column="1" Spacing="5"><TextBlock Text="{DynamicResource sheet_studio.orientation}" />- <ComboBox ItemsSource="{Binding Orientations}" SelectedValue="{Binding SelectedSheet.Orientation}" SelectedValueBinding="{Binding Value}">+ <ComboBox ItemsSource="{Binding Orientations}" SelectedValue="{Binding SelectedSheet.Orientation}" SelectedValueBinding="{Binding Value}"+ AutomationProperties.Name="{DynamicResource sheet_studio.orientation}"><ComboBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Label}" /></DataTemplate></ComboBox.ItemTemplate></ComboBox></StackPanel></Grid><TextBlock Text="{DynamicResource sheet_studio.scaling}" />- <ComboBox ItemsSource="{Binding ScaleModes}" SelectedValue="{Binding SelectedSheet.ScaleMode}" SelectedValueBinding="{Binding Value}">+ <ComboBox ItemsSource="{Binding ScaleModes}" SelectedValue="{Binding SelectedSheet.ScaleMode}" SelectedValueBinding="{Binding Value}"+ AutomationProperties.Name="{DynamicResource sheet_studio.scaling}"><ComboBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Label}" /></DataTemplate></ComboBox.ItemTemplate></ComboBox><Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" ColumnSpacing="8" RowSpacing="8">@@ -169,7 +173,8 @@</Grid><TextBlock Text="{DynamicResource sheet_studio.page_order}" />- <ComboBox ItemsSource="{Binding PageOrders}" SelectedValue="{Binding SelectedSheet.Order}" SelectedValueBinding="{Binding Value}">+ <ComboBox ItemsSource="{Binding PageOrders}" SelectedValue="{Binding SelectedSheet.Order}" SelectedValueBinding="{Binding Value}"+ AutomationProperties.Name="{DynamicResource sheet_studio.page_order}"><ComboBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Label}" /></DataTemplate></ComboBox.ItemTemplate></ComboBox><CheckBox Content="{DynamicResource sheet_studio.include_hidden}" IsChecked="{Binding SelectedSheet.IncludeHidden}" />diff --git a/src/Filee.Engines/Pdf/PdfPagePreview.cs b/src/Filee.Engines/Pdf/PdfPagePreview.csindex 36f3a5b4..e5e4d5b3 100644--- a/src/Filee.Engines/Pdf/PdfPagePreview.cs+++ b/src/Filee.Engines/Pdf/PdfPagePreview.cs@@ -89,13 +89,3 @@ public sealed class PdfPreviewDocument?? throw new InvalidOperationException("The PDF preview could not be resized.");}}--public static class PdfPagePreviewRenderer-{- public static IReadOnlyList<RenderedPdfPage> Render(string path, int maxLongEdge = 1400,- CancellationToken cancellationToken = default)- {- var document = PdfPreviewDocument.Open(path);- return document.RenderThumbnails(maxLongEdge, cancellationToken);- }-}diff --git a/tests/Filee.App.Tests/SpreadsheetPrintStudioTests.cs b/tests/Filee.App.Tests/SpreadsheetPrintStudioTests.csindex 52babf38..b9e20921 100644--- a/tests/Filee.App.Tests/SpreadsheetPrintStudioTests.cs+++ b/tests/Filee.App.Tests/SpreadsheetPrintStudioTests.cs@@ -11,6 +11,40 @@ namespace Filee.App.Tests;public class SpreadsheetPrintStudioTests{+ [AvaloniaFact]+ public void Multiple_workbooks_keep_independent_studio_windows()+ {+ TestServices.EnsureInitialized();+ var folder = Directory.CreateTempSubdirectory("filee-studios-test-").FullName;+ var windows = AppHost.Get<WindowService>();+ var before = windows.SpreadsheetStudios.ToArray();+ try+ {+ var first = Path.Combine(folder, "first.xlsx");+ var second = Path.Combine(folder, "second.xlsx");+ WriteWorkbook(first);+ WriteWorkbook(second);++ windows.ShowSpreadsheetPrintStudio(first);+ windows.ShowSpreadsheetPrintStudio(second);++ var opened = windows.SpreadsheetStudios.Except(before).ToArray();+ Assert.Equal(2, opened.Length);+ Assert.All(opened, window => Assert.True(window.IsVisible));+ Assert.Equal(["first.xlsx", "second.xlsx"], opened.Select(window =>+ ((SpreadsheetPrintStudioViewModel)window.DataContext!).FileName).Order());+ opened[0].Close();+ Assert.True(opened[1].IsVisible);+ Assert.DoesNotContain(opened[0], windows.SpreadsheetStudios);+ }+ finally+ {+ foreach (var window in windows.SpreadsheetStudios.Except(before).ToArray())+ window.Close();+ try { Directory.Delete(folder, recursive: true); } catch (IOException) { }+ }+ }+[AvaloniaFact]public async Task Closing_during_export_cancels_LibreOffice_and_removes_temporary_files(){diff --git a/tests/Filee.App.Tests/ToolbarEditorTests.cs b/tests/Filee.App.Tests/ToolbarEditorTests.csindex 50101f0c..0282d239 100644--- a/tests/Filee.App.Tests/ToolbarEditorTests.cs+++ b/tests/Filee.App.Tests/ToolbarEditorTests.cs@@ -511,8 +511,7 @@ public class PresetAvailabilityTestsAssert.Null(f.Availability.Check(studio, [Fixture.Format("xlsx")]));Assert.Equal(f.Loc["error.unsupported_source"],f.Availability.Check(studio, [Fixture.Format("ods")]));- Assert.Equal(f.Loc["error.unsupported_source"],- f.Availability.Check(studio, [Fixture.Format("xlsx"), Fixture.Format("xlsx")]));+ Assert.Null(f.Availability.Check(studio, [Fixture.Format("xlsx"), Fixture.Format("xlsx")]));libreOffice.Available = false;Assert.Equal(f.Loc["error.no_route"],diff --git a/tests/Filee.Engines.Tests/SpreadsheetPrintPlanTests.cs b/tests/Filee.Engines.Tests/SpreadsheetPrintPlanTests.csindex bbcf6f2d..2b3d8b48 100644--- a/tests/Filee.Engines.Tests/SpreadsheetPrintPlanTests.cs+++ b/tests/Filee.Engines.Tests/SpreadsheetPrintPlanTests.cs@@ -2,9 +2,9 @@ using System.IO.Compression;using System.Xml.Linq;using Filee.Core.Conversion;using Filee.Core.Presets;+using Filee.Engines.Infrastructure;using Filee.Engines.Office;using Filee.Engines.Office.Sheets;-using Filee.Engines.Infrastructure;using static Filee.Engines.Tests.XlsxBuilder;namespace Filee.Engines.Tests;@@ -254,7 +254,8 @@ public class SpreadsheetPrintPlanTestspdf.Save(path);}- var pages = Filee.Engines.Pdf.PdfPagePreviewRenderer.Render(path, 400, TestContext.Current.CancellationToken);+ var preview = Filee.Engines.Pdf.PdfPreviewDocument.Open(path);+ var pages = preview.RenderThumbnails(400, TestContext.Current.CancellationToken);Assert.Equal(2, pages.Count);Assert.True(pages[0].Height > pages[0].Width);