diff --git a/Common/DaisyConverterLib/AddinLogger.cs b/Common/DaisyConverterLib/AddinLogger.cs index 0b7d745..0e4e90c 100644 --- a/Common/DaisyConverterLib/AddinLogger.cs +++ b/Common/DaisyConverterLib/AddinLogger.cs @@ -71,5 +71,15 @@ public static void Info(string messsage) { _log.Info(messsage); } - } + + public static void Warning(string messsage) + { + _log.Warn(messsage); + } + + public static void Warning(string messsage, Exception ex) + { + _log.Warn(messsage, ex); + } + } } \ No newline at end of file diff --git a/Installer/DaisyAddinForWordSetup/Product.wxs b/Installer/DaisyAddinForWordSetup/Product.wxs index a6ece50..7f2e711 100644 --- a/Installer/DaisyAddinForWordSetup/Product.wxs +++ b/Installer/DaisyAddinForWordSetup/Product.wxs @@ -270,25 +270,25 @@ both x86 and x64 msi can then use the same cab for install ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> - + - + - + - + @@ -298,11 +298,11 @@ - + - + @@ -374,7 +374,7 @@ - + @@ -382,13 +382,13 @@ - + - + @@ -396,16 +396,16 @@ - + - + - + @@ -413,7 +413,7 @@ - + @@ -427,7 +427,7 @@ - + @@ -444,7 +444,7 @@ - + @@ -452,7 +452,7 @@ - + @@ -468,7 +468,7 @@ - + @@ -476,7 +476,7 @@ - + @@ -484,7 +484,7 @@ - + @@ -492,7 +492,7 @@ - + @@ -500,7 +500,7 @@ - + @@ -508,7 +508,7 @@ - + @@ -516,7 +516,7 @@ - + @@ -524,7 +524,7 @@ - + @@ -532,7 +532,7 @@ - + @@ -540,7 +540,7 @@ - + @@ -548,7 +548,7 @@ - + @@ -561,7 +561,7 @@ - + @@ -569,7 +569,7 @@ - + @@ -579,7 +579,7 @@ - + @@ -594,7 +594,7 @@ - + @@ -607,11 +607,11 @@ - + - + @@ -683,13 +683,13 @@ - + - + @@ -697,13 +697,13 @@ - + - + @@ -711,16 +711,16 @@ - + - + - + @@ -728,7 +728,7 @@ - + @@ -742,7 +742,7 @@ - + @@ -759,7 +759,7 @@ - + @@ -767,7 +767,7 @@ - + @@ -783,7 +783,7 @@ - + @@ -791,7 +791,7 @@ - + @@ -799,7 +799,7 @@ - + @@ -807,7 +807,7 @@ - + @@ -815,7 +815,7 @@ - + @@ -823,7 +823,7 @@ - + @@ -831,7 +831,7 @@ - + @@ -839,7 +839,7 @@ - + @@ -847,7 +847,7 @@ - + @@ -855,7 +855,7 @@ - + @@ -863,7 +863,7 @@ - + @@ -876,7 +876,7 @@ - + @@ -884,7 +884,7 @@ - + @@ -894,7 +894,7 @@ - + @@ -909,7 +909,7 @@ - + @@ -923,7 +923,7 @@ - + @@ -962,17 +962,17 @@ - - + + - - - + + + @@ -981,19 +981,19 @@ - + - + - + @@ -1012,7 +1012,7 @@ - + @@ -1026,16 +1026,16 @@ - + - + - + @@ -1051,7 +1051,7 @@ - + @@ -1061,7 +1061,7 @@ - + @@ -1070,7 +1070,7 @@ - + diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-common-3.0.1.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-common-3.0.2.jar similarity index 83% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-common-3.0.1.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-common-3.0.2.jar index 5186522..af77445 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-common-3.0.1.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-common-3.0.2.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-css-utils-2.1.0.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-css-utils-2.1.1.jar similarity index 89% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-css-utils-2.1.0.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-css-utils-2.1.1.jar index fc7bb78..7474735 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-css-utils-2.1.0.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.braille-css-utils-2.1.1.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.1.0-windows.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.2.0-windows.jar similarity index 62% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.1.0-windows.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.2.0-windows.jar index 7469e7a..175995a 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.1.0-windows.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.2.0-windows.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.1.1.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.2.0.jar similarity index 88% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.1.1.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.2.0.jar index 5aca36a..70d26e2 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.1.1.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.liblouis-utils-5.2.0.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.pef-utils-5.0.3.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.pef-utils-5.0.4.jar similarity index 86% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.pef-utils-5.0.3.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.pef-utils-5.0.4.jar index 6a14194..c76cc64 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.pef-utils-5.0.3.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.braille.pef-utils-5.0.4.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy202-utils-1.6.0.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy202-utils-1.6.1.jar similarity index 62% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy202-utils-1.6.0.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy202-utils-1.6.1.jar index 55ddd7a..ecc5573 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy202-utils-1.6.0.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy202-utils-1.6.1.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy3-utils-4.1.1.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy3-utils-4.1.2.jar similarity index 87% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy3-utils-4.1.1.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy3-utils-4.1.2.jar index c92762b..cc653d7 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy3-utils-4.1.1.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.daisy3-utils-4.1.2.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-to-zedai-3.0.3.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-to-zedai-3.0.4.jar similarity index 66% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-to-zedai-3.0.3.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-to-zedai-3.0.4.jar index 791188c..5c2aeb0 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-to-zedai-3.0.3.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-to-zedai-3.0.4.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-utils-4.0.1-SNAPSHOT.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-utils-4.0.1-SNAPSHOT.jar index 92f98a9..2c613b6 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-utils-4.0.1-SNAPSHOT.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.dtbook-utils-4.0.1-SNAPSHOT.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.html-utils-6.2.0.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.html-utils-6.2.1.jar similarity index 92% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.html-utils-6.2.0.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.html-utils-6.2.1.jar index 0ae3cab..3863751 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.html-utils-6.2.0.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.html-utils-6.2.1.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-azure-1.0.0-SNAPSHOT.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-azure-1.0.0-SNAPSHOT.jar deleted file mode 100644 index b480be9..0000000 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-azure-1.0.0-SNAPSHOT.jar and /dev/null differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-azure-1.0.0.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-azure-1.0.0.jar new file mode 100644 index 0000000..c0af30c Binary files /dev/null and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-azure-1.0.0.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-sapinative-3.1.3-SNAPSHOT.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-sapinative-3.1.3-SNAPSHOT.jar index f2c2a4d..f7833c8 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-sapinative-3.1.3-SNAPSHOT.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-adapter-sapinative-3.1.3-SNAPSHOT.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-common-5.0.1-SNAPSHOT.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-common-5.0.1-SNAPSHOT.jar deleted file mode 100644 index c680f59..0000000 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-common-5.0.1-SNAPSHOT.jar and /dev/null differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-common-5.1.0.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-common-5.1.0.jar new file mode 100644 index 0000000..a9d3441 Binary files /dev/null and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.tts-common-5.1.0.jar differ diff --git a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.zedai-to-html-2.2.1.jar b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.zedai-to-html-2.3.0.jar similarity index 67% rename from Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.zedai-to-html-2.2.1.jar rename to Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.zedai-to-html-2.3.0.jar index 575f971..ecba046 100644 Binary files a/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.zedai-to-html-2.2.1.jar and b/Lib/daisy-pipeline/system/common/org.daisy.pipeline.modules.zedai-to-html-2.3.0.jar differ diff --git a/Word2007/DaisyWord2007AddIn/DocumentPreprocessor.cs b/Word2007/DaisyWord2007AddIn/DocumentPreprocessor.cs index 76d9e48..ebbe528 100644 --- a/Word2007/DaisyWord2007AddIn/DocumentPreprocessor.cs +++ b/Word2007/DaisyWord2007AddIn/DocumentPreprocessor.cs @@ -20,6 +20,8 @@ using System.Threading; using System.Drawing.Imaging; using System.Drawing; +using Microsoft.Office.Core; +using System.Windows.Input; namespace Daisy.SaveAsDAISY.Addins.Word2007 { @@ -159,18 +161,6 @@ public static void convertEmfBufferToPng(byte[] emfBuffer, string destinationFil } } - object missing = Type.Missing; - - // to duplicate the current doc and use the copy - object doNotAddToRecentFiles = false; - object notReadOnly = false; - - // visibility - // object visible = true; - object notVisible = false; - object originalFormat = MSword.WdOriginalFormat.wdOriginalDocumentFormat; - object format = MSword.WdSaveFormat.wdFormatXMLDocument; - protected MSword.Application currentInstance; public DocumentPreprocessor(MSword.Application WordInstance) { currentInstance = WordInstance; @@ -180,19 +170,72 @@ public ConversionStatus CreateWorkingCopy(ref object preprocessedObject, ref Doc MSword.Document currentDoc = (MSword.Document)preprocessedObject; object tmpFileName = document.CopyPath; - object originalPath = document.InputPath; - // Save a copy to start working on if (File.Exists((string)tmpFileName)) { File.Delete((string)tmpFileName); } - currentDoc.SaveAs(ref tmpFileName, ref format, ref missing, ref missing, ref doNotAddToRecentFiles, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); - currentDoc.Close(); + // Create an empty document to start the copy + MSword.Document copy = currentInstance.Documents.Add( + Visible: false + ); + try { + + // Copy styles + foreach (MSword.Style style in currentDoc.Styles) { + try { + currentInstance.OrganizerCopy(currentDoc.FullName, copy.FullName, style.NameLocal, MSword.WdOrganizerObject.wdOrganizerObjectStyles); + } + catch (Exception ex) { + AddinLogger.Warning("Non-critical exception raised while copying style " + style.NameLocal, ex); + } + + } + + // Copy properties + DocumentProperties currentDocProps = (DocumentProperties)currentDoc.BuiltInDocumentProperties; + DocumentProperties copyProps = (DocumentProperties)copy.BuiltInDocumentProperties; + foreach (var key in Enum.GetValues(typeof(MSword.WdBuiltInProperty))) { + try { + copyProps[key].Value = currentDocProps[key].Value; + } + catch (Exception ex) { + // exception trigger on undefined property + AddinLogger.Warning("Non-critical exception raised copying built-in property " + key.ToString(), ex); + } + + } + // Copy custom properties + DocumentProperties currentDocCustomProps = (DocumentProperties)currentDoc.CustomDocumentProperties; + DocumentProperties copyCustomProps = (DocumentProperties)copy.CustomDocumentProperties; + foreach (DocumentProperty prop in currentDocCustomProps) { + try { + copyCustomProps.Add(prop.Name, prop.LinkToContent, prop.Type, prop.Value, prop.LinkSource); + } + catch (Exception ex) { + // exception trigger on undefined property + AddinLogger.Warning("Non-critical exception raised copying custom property " + prop.Name, ex); + } + } - // only reopen the document if it is the main document (and if we want it reopened) - if (document.ResourceId == null && document.ShowInputDocumentInWord) currentInstance.Documents.Open(ref originalPath); + // Copy content + currentDoc.Content.Copy(); + copy.Content.Paste(); + Clipboard.Clear(); + + // Save new document on disk + copy.SaveAs2( + FileName: tmpFileName, + FileFormat: MSword.WdSaveFormat.wdFormatXMLDocument, + AddToRecentFiles: false + ); + // use it as proprecessed document + preprocessedObject = copy; + } catch { + // On error, close copy and forward exception + copy.Close(SaveChanges: false); + throw; + } - // Open (or retrieve) the temp file if opened in word and use it for preprocessing (document is not visible in word) - preprocessedObject = currentInstance.Documents.Open(ref tmpFileName, ref missing, ref notReadOnly, ref doNotAddToRecentFiles, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref notVisible, ref missing, ref missing, ref missing, ref missing); + return ConversionStatus.CreatedWorkingCopy; @@ -200,8 +243,10 @@ public ConversionStatus CreateWorkingCopy(ref object preprocessedObject, ref Doc public ConversionStatus endPreprocessing(ref object preprocessedObject, IConversionEventsHandler eventsHandler = null) { MSword.Document preprocessingDocument = (MSword.Document)preprocessedObject; - object dontSaveChanges = MSword.WdSaveOptions.wdDoNotSaveChanges; - preprocessingDocument.Close(ref dontSaveChanges, ref originalFormat, ref missing); + preprocessingDocument.Close( + SaveChanges: MSword.WdSaveOptions.wdDoNotSaveChanges, + OriginalFormat: MSword.WdOriginalFormat.wdOriginalDocumentFormat + ); return ConversionStatus.PreprocessingSucceeded; } @@ -416,10 +461,12 @@ public ConversionStatus ProcessShapes(ref object preprocessedObject, ref Documen } public object startPreprocessing(DocumentParameters document, IConversionEventsHandler eventsHandler = null) { - object path = (object)document.InputPath; // reset the focus on the document (or open it as visible) in the word app if it is not a subdoc - object visible = document.ResourceId == null; - return currentInstance.Documents.Open(ref path, ref missing, ref missing, ref doNotAddToRecentFiles, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref visible); + return currentInstance.Documents.Open( + FileName: document.InputPath, + AddToRecentFiles: false, + Visible: document.ResourceId == null + ); } public ConversionStatus ValidateName(ref object preprocessedObject, StringValidator authorizedNamePattern, IConversionEventsHandler eventsHandler = null) {