From c4afb5bafa9c499b7edad63b65b103f984a9400f Mon Sep 17 00:00:00 2001 From: Nicolas Pavie Date: Thu, 14 Dec 2023 15:52:19 +0100 Subject: [PATCH] fix(#35): updated treatment of bidirectionnal text Refactored the conversion of bidirectionnal text: - Treating bdo element as inline other inline tag - Checking for w:bidi or w:rtl informations in text runner properties to add bdo elements Also: - Changed default plugin settings for more optimal default notes positionning in result - Starting to remove document name and path in exception report --- Common/DaisyConverterLib/Converter.cs | 12 +- Common/DaisyConverterLib/ConverterSettings.cs | 34 ++-- .../DaisyConverterLib.csproj | 2 + .../resources/xslts/Common.xsl | 170 ++++++++---------- .../resources/xslts/Common3.xsl | 138 ++++---------- .../resources/xslts/oox2Daisy.xsl | 57 ------ 6 files changed, 132 insertions(+), 281 deletions(-) diff --git a/Common/DaisyConverterLib/Converter.cs b/Common/DaisyConverterLib/Converter.cs index bf3b87e..c41ea4f 100644 --- a/Common/DaisyConverterLib/Converter.cs +++ b/Common/DaisyConverterLib/Converter.cs @@ -323,14 +323,14 @@ public ConversionResult Convert(DocumentParameters document, bool applyPostProce } catch (Exception e) { - string message = "An error occured while converting " + document.InputPath + " to dtbook XML :\r\n" + e.Message; + string message = "An error occured while converting a single docx to dtbook XML"; while (e.InnerException != null) { message += "\r\n - " + e.InnerException.Message; e = e.InnerException; } - Exception fault = new Exception("An error occured while converting " + document.InputPath + " to dtbook XML :\r\n" + e.Message, e); + Exception fault = new Exception("Conversion of single docx to dtbook XML: task crashed", e); this.EventsHandler.OnConversionError( fault ); @@ -349,7 +349,7 @@ public ConversionResult Convert(DocumentParameters document, bool applyPostProce e = e.InnerException; } - Exception fault = new Exception("An error occured while converting " + document.InputPath + " to dtbook XML :\r\n" + e.Message, e); + Exception fault = new Exception("Conversion of single docx to dtbook XML: task ended in fault", e); this.EventsHandler.OnConversionError( fault ); @@ -383,7 +383,7 @@ public ConversionResult Convert(DocumentParameters document, bool applyPostProce catch (Exception e) { CurrentStatus = ConversionStatus.Error; - Exception fault = new Exception("Error while converting with DAISY Pipeline 2:\r\n" + e.Message, e); + Exception fault = new Exception("Error while converting with DAISY Pipeline 2", e); this.EventsHandler.onPostProcessingError( fault ); @@ -466,7 +466,7 @@ public ConversionResult Convert(List documentLists, bool app } catch (Exception e) { - Exception fault = new Exception("Error while converting " + document.InputPath + " to dtbook XML:\r\n" + e.Message, e); + Exception fault = new Exception("Conversion of list of docx to dtbook XML: task crashed", e); // TODO try to see if exception is raised by cancellation this.EventsHandler.OnConversionError(fault); throw fault; @@ -475,7 +475,7 @@ public ConversionResult Convert(List documentLists, bool app if (conversionTask.IsFaulted) { - Exception fault = new Exception("Error while converting " + document.InputPath + " to dtbook XML:\r\n" + conversionTask.Exception.Message, conversionTask.Exception); + Exception fault = new Exception("Conversion of list of docx to dtbook XML: task ended in fault", conversionTask.Exception); this.EventsHandler.OnConversionError( fault ); diff --git a/Common/DaisyConverterLib/ConverterSettings.cs b/Common/DaisyConverterLib/ConverterSettings.cs index 58dc969..5e3d734 100644 --- a/Common/DaisyConverterLib/ConverterSettings.cs +++ b/Common/DaisyConverterLib/ConverterSettings.cs @@ -143,12 +143,12 @@ public enum Enum private string resampleValue = "96"; private string characterStyle = "False"; private string pagenumStyle = "Custom"; - private string footnotesLevel = "0"; // 0 mean current paragraphe, < 0 means parent level going upward, > 1 means absolute dtbook level - private string footnotesPosition = "page"; // Should be inline, end, or page - private string footnotesNumbering = "number"; // should be number, none, or word (to reuse word + private string footnotesLevel = "0"; // 0 mean current paragraphe level, < 0 means parent level going upward, > 1 means absolute dtbook level + private string footnotesPosition = "end"; // Should be inline, end, or page + private string footnotesNumbering = "none"; // should be number, none, or word private string footnotesStartValue = "1"; // number to be used private string footnotesNumberingPrefix = ""; // prefix to be added before the numbering - private string footnotesNumberingSuffix = " "; // suffix to be added between the number and the text (default to a space to reproduce the plugin original behaviour) + private string footnotesNumberingSuffix = ""; // suffix to be added between the number and the text private string azureSpeechRegion = ""; // region defined in the Azure console for the speech service private string azureSpeechKey = ""; // one of the two keys provided to connect to to Azure speech synthesis service private string ttsConfigFile = ""; // A tts config file to use for speech synthesis with pipeline 2 @@ -156,19 +156,19 @@ private string SettingsXml { get => $"" + - $"" + - $"" + - $"" + - $"" + - $"" + - $"" + - $""; + $"\r\n\t" + + $"\r\n\t" + + $"\r\n\t" + + $"\r\n\t" + + $"\r\n\t" + + $"\r\n\t" + + $"\r\n"; } diff --git a/Common/DaisyConverterLib/DaisyConverterLib.csproj b/Common/DaisyConverterLib/DaisyConverterLib.csproj index ba6e677..0706f3a 100755 --- a/Common/DaisyConverterLib/DaisyConverterLib.csproj +++ b/Common/DaisyConverterLib/DaisyConverterLib.csproj @@ -291,9 +291,11 @@ PreserveNewest + Designer PreserveNewest + Designer PreserveNewest diff --git a/Common/DaisyConverterLib/resources/xslts/Common.xsl b/Common/DaisyConverterLib/resources/xslts/Common.xsl index 4a77b3f..9817b9d 100644 --- a/Common/DaisyConverterLib/resources/xslts/Common.xsl +++ b/Common/DaisyConverterLib/resources/xslts/Common.xsl @@ -252,7 +252,7 @@ - progress:Converting element / + progress:Converting element - / - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1119,13 +1107,6 @@ - - - - - - - @@ -1615,47 +1596,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + + + + @@ -2167,15 +2108,6 @@ - @@ -2210,7 +2142,7 @@ + select="concat('<', $styleTag, ' ', normalize-space($attributes), '>')"/> @@ -2234,14 +2166,38 @@ - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2285,10 +2241,22 @@ + + + + + + - - + + + + + + dir="rtl" xml:lang="" + + @@ -2321,6 +2289,9 @@ + + + @@ -2333,6 +2304,9 @@ + + + @@ -3595,7 +3569,9 @@ - + + + " @@ -3745,7 +3721,9 @@ - + + + " diff --git a/Common/DaisyConverterLib/resources/xslts/Common3.xsl b/Common/DaisyConverterLib/resources/xslts/Common3.xsl index ab84caa..86bbfdf 100644 --- a/Common/DaisyConverterLib/resources/xslts/Common3.xsl +++ b/Common/DaisyConverterLib/resources/xslts/Common3.xsl @@ -2605,130 +2605,58 @@ - - - debug in BdoLanguages - " - - - - - + + + + debug in GetBdoLanguages - + + - - + + - + + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - debug in BdoRtlLanguages - " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + debug in TempCharacterStyle diff --git a/Common/DaisyConverterLib/resources/xslts/oox2Daisy.xsl b/Common/DaisyConverterLib/resources/xslts/oox2Daisy.xsl index 0b922c0..daead21 100644 --- a/Common/DaisyConverterLib/resources/xslts/oox2Daisy.xsl +++ b/Common/DaisyConverterLib/resources/xslts/oox2Daisy.xsl @@ -315,63 +315,6 @@ - - progress:Starting conversion of elements