private static void SaveOptionsAndExport(TextDocument document, OpenXMLExportOptions exportOptions)
        {
            document.PropertyBagNotNull.SetValue(PropertyKeyOpenXMLExportOptions, (OpenXMLExportOptions)exportOptions.Clone());
            Current.PropertyService.ApplicationSettings.SetValue(PropertyKeyOpenXMLExportOptions, (OpenXMLExportOptions)exportOptions.Clone());

            var errors = new List <MarkdownError>();

            exportOptions.Export(document, exportOptions.OutputFileName, errors);

            if (errors.Count > 0)
            {
                var stb = new StringBuilder();
                stb.AppendLine("There were error(s) during export:");
                stb.AppendLine();

                foreach (var error in errors)
                {
                    stb.AppendLine(error.ToString());
                }

                Current.Gui.ErrorMessageBox(stb.ToString(), "Export errors");
                return;
            }


            // Start Sandcastle help file builder
            if (exportOptions.OpenApplication)
            {
                System.Diagnostics.Process.Start(exportOptions.OutputFileName);
            }
        }
            public void Deserialize(OpenXMLExportOptions s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                s.ExpandChildDocuments = info.GetBoolean("ExpandChildDocuments");
                s.MaximumImageWidth    = (Altaxo.Units.DimensionfulQuantity?)info.GetValue("MaxImageWidth", s);
                s.MaximumImageHeight   = (Altaxo.Units.DimensionfulQuantity?)info.GetValue("MaxImageHeight", s);
                //if (info.CurrentElementName == "ImageResolution")
                s.ImageResolutionDpi = info.GetInt32("ImageResolution");

                s.ThemeName = info.GetString("ThemeName");
                //if (info.CurrentElementName == "RemoveOldContent")
                s.RemoveOldContentsOfTemplateFile = info.GetBoolean("RemoveOldContent");
                s.OpenApplication = info.GetBoolean("OpenApplication");
                s.OutputFileName  = info.GetString("OutputFileName");

                if (info.CurrentElementName == "RenumerateFigures")
                {
                    s.RenumerateFigures                  = info.GetBoolean("RenumerateFigures");
                    s.UseAutomaticFigureNumbering        = info.GetBoolean("UseAutomaticFigureNumbering");
                    s.DoNotFormatFigureLinksAsHyperlinks = info.GetBoolean("DoNotFormatFigureLinksAsHyperlinks");
                }
            }