diff --git a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Integration.cs b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Integration.cs index b0d022a2e..f337064e9 100644 --- a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Integration.cs +++ b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Integration.cs @@ -4,6 +4,7 @@ using Sdl.Community.PostEdit.Versions.HTMLReportIntegration.ReportManaging; using Sdl.Community.PostEdit.Versions.HTMLReportIntegration.ReportView; using Sdl.Community.PostEdit.Versions.HTMLReportIntegration.ReportView.Model; +using Sdl.Community.PostEdit.Versions.HTMLReportIntegration.Ribbon; using Sdl.Community.PostEdit.Versions.HTMLReportIntegration.Studio; using Sdl.Community.PostEdit.Versions.HTMLReportIntegration.Studio.Components; using Sdl.TranslationStudioAutomation.IntegrationApi; @@ -23,6 +24,7 @@ public class Integration private static ReportViewController ReportViewController => _reportViewController ??= SdlTradosStudio.Application.GetController(); + private static StudioController StudioController { get; } = new(); public static async Task ExportReport() @@ -61,6 +63,8 @@ public static void HandleReportRequest(string jsonMessage) public static void InitializeReportFilter(string projectId) { + if (projectId == null) return; + var reportFilter = SdlTradosStudio.Application.GetController(); reportFilter.Activate(); @@ -138,5 +142,10 @@ private static void EditorEventListener_CommentsChanged(List commen private static void EditorEventListener_StatusChanged(string newStatus, string segmentId, string fileId) => ReportViewController.UpdateStatus(newStatus, segmentId, fileId); + + public static void ToggleSyncRibbon(bool state) + { + SdlTradosStudio.Application.GetAction().Enabled = state; + } } } \ No newline at end of file diff --git a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportManaging/Components/ExcelConverter.cs b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportManaging/Components/ExcelConverter.cs index c5b0d9f7e..e7bd01b85 100644 --- a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportManaging/Components/ExcelConverter.cs +++ b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportManaging/Components/ExcelConverter.cs @@ -79,18 +79,31 @@ private static void SaveTableToExcel(List tableNodes, string filePath) private static void AddRowToWorksheet(ExcelWorksheet ws, HtmlNodeCollection cells, int excelRow) { - var excelCol = 1; + int excelCol = 1; foreach (var cell in cells) { var cellText = HttpUtility.HtmlDecode(cell.InnerText.Trim()); var cellRef = ws.Cells[excelRow, excelCol]; - if (cellText.EndsWith("%") && double.TryParse(cellText.TrimEnd('%'), NumberStyles.Any, CultureInfo.InvariantCulture, out var percentageValue)) + if (excelRow > 1 && excelCol == 6) + { + // Extract inner HTML and parse it to get text content from elements + var innerHtml = cell.InnerHtml; + var doc = new HtmlDocument(); + doc.LoadHtml(innerHtml); + var statusParts = doc.DocumentNode.SelectNodes("//span") + .Select(span => HttpUtility.HtmlDecode(span.InnerText.Trim())) + .Where(part => !string.IsNullOrWhiteSpace(part)) + .ToArray(); + cellText = string.Join("\n", statusParts); + } + + if (cellText.EndsWith("%") && double.TryParse(cellText.TrimEnd('%'), NumberStyles.Any, CultureInfo.InvariantCulture, out double percentageValue)) { cellRef.Value = percentageValue / 100; cellRef.Style.Numberformat.Format = "0.00%"; } - else if (double.TryParse(cellText, NumberStyles.Any, CultureInfo.InvariantCulture, out var numericValue)) + else if (double.TryParse(cellText, NumberStyles.Any, CultureInfo.InvariantCulture, out double numericValue)) { cellRef.Value = numericValue; cellRef.Style.Numberformat.Format = "#,##0.00"; diff --git a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportView/ReportViewController.cs b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportView/ReportViewController.cs index 1e5f75fae..b7a6e15e6 100644 --- a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportView/ReportViewController.cs +++ b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/ReportView/ReportViewController.cs @@ -78,25 +78,27 @@ protected override void Initialize(IViewContext context) private void AttachEvents() { - ReportExplorer.SelectedReportChanged += ExplorerOnSelectedReportChanged; + ReportExplorer.SelectedReportChanged += Explorer_SelectedReportChanged; ReportViewer.WebMessageReceived += WebView2Browser_WebMessageReceived; } - private async void ExplorerOnSelectedReportChanged() + private async void Explorer_SelectedReportChanged() { try { + var selectedReport = GetSelectedReport(); + Integration.ToggleSyncRibbon(selectedReport is not null); + await ReportViewer.Navigate(ReportExplorerViewModel.SelectedReport?.ReportPath); await Task.Delay(500); - var projectId = await ReportViewer.GetProjectId(); - if (projectId == null) return; + var projectId = await ReportViewer.GetProjectId(); Integration.InitializeReportFilter(projectId); } catch (Exception e) { ReportExplorerViewModel.SelectedReport = null; - ErrorHandler.ShowError($"Error loading the selected report: {e.Message}", null); + ErrorHandler.ShowError($"Error loading the selected report: {e.Message}"); } } diff --git a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Ribbon/SynchronizationRibbonGroup.cs b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Ribbon/SynchronizationRibbonGroup.cs index d1eb2b35c..7dd5f630f 100644 --- a/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Ribbon/SynchronizationRibbonGroup.cs +++ b/Post Edit Compare/Sdl.Community.PostEdit.Compare.Versions/HTMLReportIntegration/Ribbon/SynchronizationRibbonGroup.cs @@ -39,6 +39,11 @@ protected override void Execute() [ActionLayout(typeof(SynchronizationRibbonGroup), 10, DisplayType.Large)] public class SyncReportProjectOn : AbstractAction { + public SyncReportProjectOn() + { + Enabled = false; + } + protected override void Execute() { SdlTradosStudio.Application.GetAction().Enabled = true;